Ensure that the shutdown function is set before a session is started