Added error handling and logout from FB on exit