since we're not stopping the thread ourselves in the code, you need to set the thread as daemon with seDaemon(True)