Fix sometimes-broken OAuth popup on iOS.

If you log in and out repeatedly, the popup would fail to close every few
times. My guess is that we can't close the OAuth popup while the last
navigation is still in progress.

Also clean up event listeners on popup exit.