code: def stop(self):
          
          if self.server.eio.async_mode == 'threading':
              func = flask.request.environ.get('werkzeug.server.shutdown')
              if func:
                  func()
              else:
                  raise RuntimeError('Cannot stop unknown web server')
          elif self.server.eio.async_mode == 'eventlet':
              raise SystemExit
          elif self.server.eio.async_mode == 'gevent':
              self.wsgi_server.stop()
docs: Stop a running SocketIO web server.
  
          This method must be called from a HTTP or SocketIO handler function.