added check if all threads are stopped