macOS has built-in functions for this that you can either trigger by sending the cmd+w or cmd+q shortcuts from BTT or by using the predefined action „Trigger Menubar Menu Item“ (sending shortcuts is easier)
I have cmd + q disabled using karabiner (to avoid quitting applications mistakenly while doing other hotkeys)
And cmd + w doesn’t close the current window when you’re using an app that has multiple tabs. (There’s also no menu item for “Close Current Window” when using chrome)
Anyways, using the apple script seems fine but just wanted to report that the UX here isn’t the best because we have to do workarounds instead of just having a simple “Close Active Window” and “Quit Active App” commands.
Of course, this also works with BTT cmd + Q does nothing (no action). You could also set cmd + Q + Q to quit an app. It's unlikely that you would type this by mistake.
As far as I know, Chrome windows are closed with cmd + shift + W. You can customize this as you wish with BTT.
I feel like we're discussing how to work around something very simple.. we have commands for all of the important things why not have commands for quit active app and close active window? It's just a strange omissions. Anyways the apple script solution works. Appreciate your replies