title: Python redirect output after os._exit
body: <p>I have thread which is supposed to close whole application, so I use os._exit(1). But I also want to redirect output from my program to file and the output file is empty after all. Simple example:</p>
  
  <pre><code>import os
  
  print('something')
  os._exit(1)
  </code></pre>
  
  <p>Running program with:</p>
  
  <pre><code>python myprogram.py &gt; output.txt
  </code></pre>
  
  <p>Is there any way to do this?</p>