Allow states to specify `onBeforeExit` hooks to act like `window.onbeforeunload`

Example:

```javascript
{
  ...
  onBeforeUnload: ['$window', 'dirty', function($window, dirty) {
    return $window.confirm("Are you sure you would like to navigate?");
  }
  ...
}
```