cleaning and logout function