wait on stopping the threads instead of sleeping