def METHOD_NAME(self, loop: asyncio.AbstractEventLoop, context):
    exc = context.get("exception")
    if exc:
        loop.stop()
        if self._idle_asyncio_handle:
            # clean it up to prevent old callbacks
            # from messing things up if loop is restarted
            self._idle_asyncio_handle.cancel()
            self._idle_asyncio_handle = None
        if not isinstance(exc, ExitMainLoop):
            # Store the exc_info so we can re-raise after the loop stops
            self._exc = exc
    else:
        loop.default_exception_handler(context)