How do you make it so that when you click the 'close / X' button in the corner, you get a message box - like in MS Word etc, BEFORE ending

Thanx