How do I disable red X close button in Unity

Tried the following :

IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle;
IntPtr hSystemMenu = GetSystemMenu( hWnd, false );
EnableMenuItem( hSystemMenu, SC_CLOSE, MF_DISABLED );
RemoveMenu( hSystemMenu, SC_CLOSE, MF_BYCOMMAND );

It did not work for me.

Please help!

Use Application.CancelQuit.

I believe you cannot disable it becuase it is a core Windows function. Its like disabling the start orb.