fix(session): session unavailable in shutdown functions

shutdown functions defined in plugin can't access information in session
because this was already closed.
Merge pull request #6755 from ewinslow/session-shutdown-timing

fix(session): session unavailable in shutdown functions