Add pthread_cancel replacement through atomic_flag instead of using pthread_kill(thread, 0). Fixes https://github.com/termux/termux-packages/issues/4378.