That's not what I meant. I said *inside* the thread there's a race condition between `err` and `out` because they are different streams. Using `out` only fixes the problem. 
How do you suggest doing this instead of using a shutdown hook?