How to suspend a virtual machine using AppleScript (when hibernating the Mac)?
Sleep/wake cannot trigger scripts. EventScripts, although it is a very impressive program. it not fit this purpose it does NOT actually appear to be able to trigger scripts quickly enough before your Mac goes to sleep.

but there are many third party solutions. For example,  sleepwatcher