title: closing files of a killed process
body: <p>python: 3.4</p>
  
  <p>OS: win7 / win10</p>
  
  <p>I want to kill a running process with python and close all the files it opened:</p>
  
  <pre><code>for proc in psutil.process_iter():
      if proc.name() == 'myprocess.exe':
          opened = proc.open_files()
          proc.kill()
          for i in opened:
              print(i.path)
              io.FileIO(i.path).close()
              print(io.FileIO(i.path).closed)
  </code></pre>
  
  <p>Somehow <code>io.IOBase(i.path).close()</code> does not work.</p>
  
  <p>Explanation:</p>
  
  <p>It's like I would like to kill Microsoft Word with python, but it leaves some files open. And I would like to close those files as well.</p>
  
  <p>Microsoft Word is just an example. It is a self-written python programm. The opened files are:</p>
  
  <ul>
  <li>fonts (.ttf)</li>
  <li>clr.pyd </li>
  <li>and .dll-s</li>
  </ul>
  
  <p>How should I close these files?</p>