That was exactly when we encountered deadlock.  The dump always showed that the process has exited but the stdout and stderr still have blocking read.  This fix is to force close both streams.   We will only do this when they are idle (see if check a few lines above).  I hope that closing the streams would force their pending Read to abort freeing up the reading threads.   

If this is not freeing those threads, we have the worst situation where threads leak.  We will wait and see the stress result before putting in even more codes.