fix(session): Explicitly closing the session in the shutdown hook to work around APC session problems.

Fixes #7186.