How to close the window and quit the application when you press ESC key under OS X?

Solution 1:

Off the top of my head:

Downlod KeyRemap4Macbook http://pqrs.org/macosx/keyremap4macbook/

See if you can't find a setting for escape, I'm not sure if there is one. Remap it to Command + Q.