Close the window and stops the worker thread. The main thread will
        resume with the next command after the `start()` call.

def stop(self):
        """
        Close the window and stops the worker thread. The main thread will
        resume with the next command after the `start()` call.
        """
        assert threading.current_thread() == self.thread
        assert self.state.running
        self.state.running = False