code: def stop(self):
          
          # Signal the thread to stop before handling the next request
          self._listener_thread.stop_flag.set()
          # Send a dummy request in case the http server is currently listening
          try:
              urlopen(
                  'http://%s:%s/' % (self.address[0], self.address[1]))
          except URLError:
              # If the server is already shut down, we receive a socket error,
              # which we ignore.
              pass
          # wait for the thread to finish
          self._listener_thread.join()
          self.is_running = False
          log.info("Event listener stopped")
docs: Stop the event listener.