Fix (unintended) race condition.

Because return 0 is used in main, there is a chance that the spawned
thread in main has not finished before return 0 is called. When main
returns, the process exits. This causes the spawned thread to exit
resulting in there being 0 chance for the bug occurring.