Launchd sends an early warning of shutdowns to all scripts/daemons that have a StopService() subroutine. This gives your process the most time to clean up.
Just use launchd to start the script and have it run in the background until it's time to exit.
After the services that got the early warning are closing down, All processes get a SIGTERM signal a few seconds before the SIGKILL nukes them.
You could make a script that sleeps and traps SIGTERM to run your command when that time comes. You will have to see if that allows enough time in practice for the commands to execute. This avoids a little bit of coding, but not much - it's generally better to just make a daemon out of a shell script.
From a historical perspective - /sbin/reboot and runlevels never existed on Darwin / OS X and rc.shutdown is deprecated along with the rest of rc now that launchd is the boss. You might be able to use rc.shutdown on tiger or earlier (I don't have one of those images handy to check presently) Lion certainly has removed all vestiges of rc.d and init.d.
You might want to see if sleepwatcher would help in your case. I haven't used it in quite a while - but it certainly aims to solve your dilemma.
/etc/rc.shutdown.localto run it when shutting down. It sounds like that's what you're looking for. – michaelmichael Jul 5 '11 at 14:54