Fixed uncaught BadWindow in EWMH check.

Fixes #234.