With virtualbox, I use VBoxManage controlvm "$VMNAME" acpipowerbutton
to shut down a virtual server when the host is shutting down.
This works well when I test, but not in real world cases (i.e. when the host reboots for updates, or even sometimes when it is manually restarted for maintenance). In some of these cases, the VM does not shut down, and after a timeout the virtualbox process is killed, which is less than ideal.