code: def shutdown_server(self):
          
  
          if not self._closing:
              self._closing = True
          else:
              log.warning("Close is already in progress")
              return
  
          if self._server:
              self._server.close()
              yield from self._server.wait_closed()
          if self._app:
              yield from self._app.shutdown()
          if self._handler:
              try:
                  # aiohttp < 2.3
                  yield from self._handler.finish_connections(2)  # Parameter is timeout
              except AttributeError:
                  # aiohttp >= 2.3
                  yield from self._handler.shutdown(2)  # Parameter is timeout
          if self._app:
              yield from self._app.cleanup()
  
          yield from Controller.instance().stop()
  
          for module in MODULES:
              log.debug("Unloading module {}".format(module.__name__))
              m = module.instance()
              yield from m.unload()
  
          if PortManager.instance().tcp_ports:
              log.warning("TCP ports are still used {}".format(PortManager.instance().tcp_ports))
  
          if PortManager.instance().udp_ports:
              log.warning("UDP ports are still used {}".format(PortManager.instance().udp_ports))
  
          for task in asyncio.Task.all_tasks():
              task.cancel()
              try:
                  yield from asyncio.wait_for(task, 1)
              except BaseException:
                  pass
  
          self._loop.stop()
docs: Cleanly shutdown the server.