I have a misbehaving hard drive that turns itself off when it detects my Mac is asleep. This is bad since OS X doesn't unmount the drive, so I get a nasty error message when the machine wakes up. Is there a way to automatically unmount the drive when the machine goes to sleep?
SleepWatcher by Bernhard Baehr seems to be what you are looking for.
Full instructions on how to set it up are available on MacOSXHints.com