Added virtual machine shutdown hook to save preferences.