code: def cleanup_event_loop(self):
          
          for task in asyncio.Task.all_tasks(loop=self.loop):
              if self.debug:
                  warnings.warn('Cancelling task: %s' % task)
              task._log_destroy_pending = False
              task.cancel()
          self.loop.close()
          self.loop.set_exception_handler(self.loop_exception_handler_save)
          self.loop_exception_handler_save = None
          self.loop_policy = None
          self.loop = None
docs: Cleanup an event loop and close it down forever.