Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's not actually true. Alt+F4 is exactly the same as clicking the Close window button, and sends WM_CLOSE to the app, which can then handle it gracefully (or not) as it chooses.

In particular, if you have unsaved data, most apps will prompt to save on Alt+F4.



Did not know that, so if an app is non responsive but alt+f4 does the trick, does that mean the app maybe wasn't as FUBAR as I thought?


When Windows sends WM_CLOSE for any reason, it will wait for some time for the app to react (not necessarily close itself, just process the message). But if it does not react soon enough, Windows will mark the app as hanging, and you'll get that standard wait-or-close dialog.

However, Alt+F4 translating to WM_CLOSE is also handled by the app message loop - i.e. Windows sends WM_KEYDOWN events for those keys, and when they get to the event loop, it's supposed to call TranslateMessage. That one normally handles WM_KEYDOWN -> WM_CHAR translation, but it will also handle any shortcuts, and this includes Alt+F4. So if the app is hanging, messages aren't pumped, and the shortcut doesn't work. To send WM_CLOSE, you'd need to use the close button on the window.

So if the app does close on Alt+F4, it was, at the minimum, pumping messages and invoking TranslateMessage on them.


Thanks for the detailed reply! I learned something today.


Yes. If you want to kill an app in Windows, use Task Manager or powershell.


Well aware of that alternative :P I had a display glitch with a game client where it would take the whole screen but not really display anything, leaving me with sound and a working computer but no display even after alt+tab or even ctrl+alt+del. I basically had to blind type win+r > "cmd" > taskkill /f /im Gw2-64bit.exe whenever it happened :(




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: