Fix warn-before-exit for phase 2

Turns out phase 1's beforeunload handler was clobbering phase 2's.