Fix bug emitting hide-window event