CA-140684: Handle cancellation of VM migration properly

Version of #1884 for master.