Fix crash.

This changes fix crashes when you have a focussed popup and we close
the window.