Wait for remote process to finish on exit