Add a hack to allow us to wait for the finalizer thread to exit using pthread_join (). This avoids some shutdown crashes, since WaitForSingleEx () would only wait for the thread's exit event to be signalled, the thread would continue to run. Hopefully fixes #4389.