code: def stop(self):
          
          try:
              self.running = False
              logger.info('Waiting tasks to finish...')
              self.queue.join()
              self.socket.close()
              logger.info('Exiting (C-Ctrl again to force it)...')
          except KeyboardInterrupt:
              logger.info('Forced.')
              sys.exit(1)
docs: Stop server and all its threads.