wait all threads to stop