How to automatically close an app when I shut down the mac?
Basically all apps will be closed when shutting down, simply because the computer will be turned off. Just to be sure: Shutting down means: Turning the computer off.

However the behavior after rebooting differs depending on the operation system version you are using. If you are running Lion or Mountain Lion there is a feature that allows to automatically  restart all open applications after rebooting/start up. In Mountain Lion you will be asked before the computer shuts down if you want the applications to be restarted after reboot. Just uncheck the checkbox.



If you're confusing shutting down with standby and/or sleep mode you will have no built-in way to solve it (but an AppleScript may help). But at least I can provide you with a shortcut: Pressing ⌘ Command  Q will "completely" close an application. You can use this shortcut instead of right clicking the dock icon to close the app.