[X11] Fixed BadWindow error on shutdown

This was caused by calling XDestroyWindow inside Dispose(), or
by processing events after calling XDestroyWindow. Pending events
are now discarded when Close() is called and not cancelled, and
XDestroyWindow is only called if the window exists.