Fix emitting unresponsive event when closing window

Fixes https://github.com/atom/atom/issues/1838.