Added endSession function.