Why are you removing all the observers, namely iren.RemoveAllObservers()?
I don’t see the window closing at all in Windows. As a tesi, I commented out iren.RemoveAllObservers() so that I could interact with the image using the mouse, and, when a key is pressed, the timer is invoked and you cannot interact with the image. Note that in this case keypress events are passed through so pressing “w” will display a wireframe before the timer is invoked. After the timer expires you can interact with the image. If you press a key again, the script exits. Note: I increased your timer interval to 10 to demonstrate this behaviour.