After doing this at least twice in 24 hours I thought I better sort this out. You can block cmd w (close window) and assign it to something else to stop this from happening.
Goto System Preferences -> Keyboard -> Keyborad Shortcuts -> Application Shortcuts
Then Add (+)
Application = X11.app Window = Close Shortcut = Whatever you want I use cmd+shift+w