I think that this could be accomplish with a user script, specifically with the command "virsh list" and "docker stop", you only have to check is the vm is present or not in the list, the main problem is the delay (VMs in SSDs starts veryfast) of the script, but probably you could just let it in a constant loop, so every 5 seconds checks if the vm is running or not.