Dont exit early, wait for the output thread to finish and dont block indefinitely