Fixed a problem when the sound engine would not shut down properly, and ...

...would stay blocking the application termination on Android (on iOS and PC this does not happen).

This would happen because StopThread() would not actually stop the thread in certain cases - probably while thread is waiting for signal from the semaphore.
So I added grace period for thread termination, so thread could gracefully exit before we call StopThread().
As far as I have tested, everything exits properly now in all cases, and application is not left hanging instead of terminating.