Wait for job file to properly close

Should prevent errors such as:
    /bin/bash: SCRIPT: /bin/bash: bad interpreter: Text file busy

Short term fix for #584.