Complete logout function.