code: async def _stop_internal(self):
          
  
          # Make sure we only try to stop once
          if self.stopping is True:
              return
  
          self.stopping = True
  
          awaitables = [task.stop() for task in self.tasks]
          results = await asyncio.gather(*awaitables, return_exceptions=True)
          for task, result in zip(self.tasks, results):
              if isinstance(result, Exception):
                  self._logger.error("Error stopping task %s: %s", task.name, repr(result))
  
          # It is important to defer this call by one loop cycle so
          # that this coroutine is finalized and anyone blocking on it
          # resumes execution.
          self.loop.call_soon(self.loop.stop)
docs: Cleanly stop the event loop after shutting down all tasks.