Cmd-W in OSX is default for close window, so that's probably it.
You say you've tried to fix it.. Have you tried these?
In Terminal.app, find the setting for "don't close this window unless no commands are running", and select it.
Or, in System Prefs/Keyboard/mappings or somesuch, override Cmd-W in Terminal.app to a noop.
Re:From Linux to OSX - 1 Year Later
by pooriaazimi on Sunday September 09, 2012 @10:24PM
(#4497984)
If by <C-w> you mean control-w (I'm a vi user and don't know!), also take a look here: http://news.ycombinator.com/item?id=4497258
Re:From Linux to OSX - 1 Year Later
by chimeracoder on Monday September 10, 2012 @12:33AM
(#4498331)
No, I already remap Caps_Lock to Esc - much more useful.
The nice thing about Linux is that I can at least remap these keybindings. On OS X, it's literally impossible to do a perfect remapping of the keys (trust me. I've tried.)
Hopefully I've saved recently (or run the process inside GNU screen....).