add logout function and destructor