Instering thread.join() to safely shut down.