You can add the Vboxmanage command to your ~/.bash_logout file and it will execute upon the logoff event.
http://askubuntu.com/questions/91829/save-virtualbox-vm-state-before-logouthttps://askubuntu.com/questions/91829/save-virtualbox-vm-state-before-logout