Not all apps use the exact same menu entry spelling, so you are going to have to create a replacement shortcut for each and every app using the exact "Close" spelling the App has in its menu.
You might be able to use a several All Application shortcuts, with one for each unique spelling an App uses to mean close.
Example changing TextEdit
This is the original TextEdit menu with "Close"

This is the Keyboard Shortcuts tab. I selected TextEdit for the Application, I entered the EXACT spelling from the TextEdit menu for closing a window "Close", and then I pressed the keys I wanted to be my TextEdit Close

Going back to TextyEdit, you can see the Menu has replaced Cmd+W with Option-Shift-Command-3

My point is that NOT ALL Applications use the same menu spelling for closing a window, and the shortcut must match the menu entry spelling exactly. In this example I'm showing you that Safari uses the menu entry "Close Window", so for Safari you have to create a shortcut using the spelling "Close Window".

You should test you shortcut for each app to make sure it is working as expected.