gh-151728: Clear the typing caches at interpreter shutdown (GH-155002)
Re-apply GH-154858, which was reverted in GH-154992 because it broke the
reference leak buildbots.
``atexit.register(_clear_caches)`` runs on every import of ``typing``, and the
registered handler reaches the module dict through ``_clear_caches.__globals__``.
Any throwaway copy of ``typing`` therefore stays alive until interpreter
shutdown. Two tests create such a copy on each iteration:
- ``InternalsTests.test_collect_parameters`` imports a fresh ``typing``.
- ``CollectionsAbcTests.test_bytestring`` drops ``typing`` from ``sys.modules``
and re-imports it.
Both now unregister the exit handler of the copy they created.