diff --git a/hotkey.py b/hotkey.py index 416bd51d..50c1b36c 100644 --- a/hotkey.py +++ b/hotkey.py @@ -296,10 +296,11 @@ elif platform == 'win32': self.thread.start() def unregister(self): - if self.thread: - PostThreadMessage(self.thread.ident, WM_QUIT, 0, 0) - self.thread.join() # Wait for it to unregister hotkey and quit - self.thread = None + thread = self.thread + if thread: + self.thread = None + PostThreadMessage(thread.ident, WM_QUIT, 0, 0) + thread.join() # Wait for it to unregister hotkey and quit def worker(self, keycode, modifiers):