joeschoe, sometimes one has to visualize how shutdown is being triggered at all. It might be by system, by admin doing remote job, by the login user himself, hence, a logoff/shutdown script in general might be advisable to restrict to biggest common denominator of these different situation. But this is not a recognized principle, just a reflection.
>it did execute myprogram.exe, it did so after closing the desktop
If you are after a shutdown script, then it'll be so. It is running under the credential of local system account. The login user is already "gone". So, it might not be very advisable or meaningful for an interactive program to run.
Maybe, think about if a logoff script will suit your situation better? I cannot be very sure.