code: def stop(self):
          
          # Exit the loop
          with self._lock:
              self._stop_event.set()
              self._shell_event.clear()
  
          if self._context is not None:
              # Unregister from events
              self._context.remove_service_listener(self)
  
              # Release the shell
              self.clear_shell()
              self._context = None
docs: Clears all members