Handle X11 issue correctly when closing window using window manager.

Fixes #10.