Apple - Disable Command-W in the terminal
To disable ⌘W in Terminal, do the following:
From the menu in the top left corner of the screen, select System Preferences. Click on Keyboard then Keyboard Shortcuts then Application Shortcuts.
Click the + button to add a new shortcut
Select "Terminal.app" for the application, and for the command, type
Close Window
(this is case sensitive). In the shortcut box, give it a different shortcut, like ⌘ControlWNow ⌘W will not close your terminal windows.
You can set a prompt before closing in the preferences:
Terminal Preferences → Settings → Shell
I tried all of the above, and none worked for me.
What worked was changing the shortcut for the "Close" command.