In my AngularJS application I use the Facebook SDK. 
When I use FB.logout() on the logout button click it works properly:
  $scope.logout = function() { 
    FB.logout() 
  }
But I also want to logout from Facebook on window close. I do the following:
  $window.onbeforeunload = function() {
    FB.logout()
   }
As you can see I do the same in both cases. However, second one does not work.
Could someone tell me, why? And how to make it work? Thanks!