How to remap "quit application" to Command+ESC system wide?
Well this sure turned out to be a question that seemed simple, but snowballed into a hassle to solve. 

I'm going to kind of start from the beginning:

Turns out disabling ⌘+Q natively is only possible if you are ok with actually just replacing it with another function. Just outright disabling it is a no go... But, some third party apps can overwrite it. I'll get to that later. Also, as simple of an idea as it seems, you can't set a new shortcut for "Quit" through the native keyboard shortcut editor thing, because that relies on the full menu item name and wouldn't you guess it, it's most often: "Quit {application name}" so it's impossible to target all apps with that single shortcut.

Then I thought... Alright, how aboutAutomator Service. I could use an apple script to close applications with that... Well, you can't set the shortcut ⌘+Esc for Automator Services apparently, but you can set that shortcut globally in some third party apps, which is the way I ended up doing it all.

Solution:

So I tried to find the cheapest third party app I have that can do all that we want to happen, enter BetterTouchTool. 

Karabiner should be able to do this for free, but a version that works in Sierra and later is under a rewrite,
 not sure if it currently has the power to do it... 


In BTT, I made a new global keyboard shortcut ⌘+Q and defined no action for it, essentially disabling it.
Then I made another shortcut: ⌘+Esc with the predefined action Run Apple Script in background:




tell application "System Events"
    set frontmostApp to name of the first application process whose frontmost is true
end tell
tell application frontmostApp to quit


You should know that this applescript should work in most applications, but not all of them. I'm not aware of a bulletproof way to do it.

This shortcut could just be "Trigger other keyboard shortcut: Cmd+Q", but since we disabled that shortcut, that is no longer an option.



That's it.