before init the new session, save and close the opened session, if necessary