function endSession