Remove popstate/hashchange event handler when app is torn down #9897
Description
When bootstrapping an app, angularjs adds an event listener to window to handle popstate and hashchange events (File /src/ng/browser.js on lines 285 and 287). This is not removed during teardown of the app, meaning that a later instance will be affected by the route/state configuration of the previous app (See issue #9877).
These handlers should be deregistered when the app's root DOM element is removed, or when $destroy() is called on an app's $rootScope. For the most part, this looks to be the only handler not attached to the app's DOM root, judging by a quick search for "jqLite(window).on", so fixing this should go a long way towards being able to fully tear down and remove every part of an angular application without requiring a page refresh.