Fix session management when logging out.