[+BUGFIX] Only serialize session if it has been initialized
As the command line mode does not use sessions, no initialized session
is available when the Object Manager tries to serialize it on
shutdown. This fix adds a check to assure that a session actually exists
before it is used.