Allow session data to be stored before the shutdown scripts execute

Sorry about the whitespace, can't figure out why github is making it different - it all lines up fine in my IDE's with various settings...