You can probably do this with the Group Policy editor. To add scripts to shutdown (and startup), run gpedit.msc then Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) > double click on Stop system.
If that's what you're looking for, then Google will help you with the scripting itself.