'This can be called from the main thread to safely stop this thread.
Note that it does not attempt to write out remaining history before
exiting. That should be done by calling the HistoryManager\'s
end_session method.'

def stop(self):

    self.stop_now = True
    self.history_manager.save_flag.set()
    self.join()
