On nearly every OS I know (now I am on MacOS):
1. System boots up and starts some apps which are creating windows. This may take some time.
2. While all of that loading, I am seeing some of the apps of no use, I am quickly switching to one, capturing focus, and pressing the quit shortcut.
3. Between my reaction and actual button press, some other app loads, and focus is switched to its window.
4. My keypress goes into another focused window, which gets closed instead of original one. Tada.
Why OS focus has a priority over user focus?