[WIP] Only force-close stdout/stderr when the job exits

stdout/stderr should only be closed after the job truly exits, or else we can lose data sent by it.

This should fix #1418