Wait for file transfer during graceful shutdown of the job. #3333

This fixes a problem introduced in my previous commit.