Use a Mutex to wait for the signal handler to fire instead of checking an atomic boolean over and over again.