Improve error handling for sign out