Wait for job file to properly close

Should prevent errors such as:
    /bin/bash: SCRIPT: /bin/bash: bad interpreter: Text file busy

Fix #584.