Added code to close the vm on shutdown.