Prevent the build stage from getting stuck

Long story short there is a race condition in the threaded build stuff that will occasionally hang winter.

Add a sleep timeout to the final wait sleep loop so that if we get a signal just after we check the loop condition, but before we sleep, we don't get stuck.