Cant unregister listener

I have a test suite that makes real API calls to the Sanic application server instance.
My test suite calls the “after_server_stop” registered listener handler after each test run, which shut down the application’s async sessions and tasks, and that makes the second test (and so on) to fail because each sequent test makes a call with a new async session and fails for “cannot schedule new futures after shutdown”

Questions are:

  1. How can I unregister a certain listener just for the test suite run
  2. What is the proper way (with code example) to keep an event loop running throughout all test suites run complete, and only then to shut sessions

My sanic, and pytest version
sanic 23.6.0
sanic-oauth 0.4.0
sanic-restful-api 0.2.0
sanic-routing 23.6.0
sanic-session 0.5.6
sanic-testing 23.6.0

pytest 7.4.3
pytest-mock 3.12.0
pytest-postgresql 5.0.0
pytest-sanic 1.9.1
pytest-timeout 2.2.0

Thank you

Take a look at the factory pattern here that is meant for this case:

Have you seen this? Maybe it will help.