Original article here.
You can make the server execute a script at shutdown time by using the Group Policy Editor, which is an MMC (Microsoft Management Console) snap-in. I will explain how to use the Group Policy Editor shortly, but first, we need to create the batch file that will shut down the Exchange services.