Instead of Sleep, we can use WaitForSingleObject with a timeout to be signalled when the service is exiting.
host