I've sometimes hit ^W, meaning to close a browser tab, and found myself leaving a channel or sometimes even disconnecting instead. The attached patch presents a confirmation-request dialogue box whenever closing a tab would result in either of those occurring.
Confirm leave/disconnect