move shutdown of session to after switch_event