Creates logout function and necessary updates