How can I have multiple virtual machines in a single job?

I need to test networking so I need multiple VMs to be online for a job and execute commands on them, my main problem derives from the fact that we cannot avoid virtual machines to stop when a job ends, do you know if is it possible a workarounf?