Ignore visibility change events when the window is closing (fixes #812).