def _watch_for_exit(self): ''' Automatically watches for termination of the main thread and then closes self gracefully. ''' main = threading.main_thread() main.join() self._stop_nowait()