Avoid spinning on CPU and stat(2) when queue empty and waiting on builders.

Regression from older [357e11da2f]
Don't hide errors from kill_and_wait
Avoid recursive err(). When exit_handler() is called, disable err() causing another exit along with set +e
Fix regression of timed_wait() crashing due to being passed too many arguments