Added check for session state before calling route->closeSession