With the tracer on, modules at shutdown can be destroyed in an order
that prevents the `trace()` function from working. This was currently
the case with Python 3.13 where the function was still being called
during the `xonsh.tracer` module's destruction.
This change adds a test to prevent this from happening in the future,
and works around the issue by creating local references to necessary
functions that were otherwise set to None at shutdown.