Wait for instances to stop

Wait for instances to stop before exiting the script when the stop
command is sent.