catch when window closes unexpectedly

specifically, if WinChan opens a popup, and the popup doesn't set up
WinChan.onOpen on the other side, then it won't fire a message before
the window closes. We still want to know when the window is closed.

also, cleanup is a little better

addresses mozilla/browserid#1773