Closes https://github.com/termux/termux-packages/issues/5485.
Note: I have replaced pthread_cancel() with pthread_exit(NULL) as Android
doesn't implement it. Not sure whether package will work correctly. If
there will be a bug, someone need to review source and replace pthread_cancel
with atomic flags in correct places.