You can associate custom VMware Tools scripts with power operations.

When VMware Tools is installed, one or more default scripts run on the guest whenever you change the power state of the virtual machine. You change the power state by using menu commands or by clicking the Suspend, Resume, Power On, and Power Off buttons. For example, when you power off a virtual machine, by default the poweroff-vm-default script runs.