title: How to open and close a PDF file from within python
body: <p>I can open a PDF file from within Python using subprocess.Popen() but I am having trouble closing the PDF file. How can I close an open PDF file using Python. My code is:</p>
  
  <pre><code># open the PDF file
  plot = subprocess.Popen('open %s' % filename, shell=True)
  
  # user inputs a comment (will subsequently be saved in a file)
  comment = raw_input('COMMENT: ')
  
  # close the PDF file
  #psutil.Process(plot.pid).get_children()[0].kill()
  plot.kill()
  </code></pre>
  
  <p>Edit: I can close the PDF immediately after opening it (using plot.kill()) but this does not work if there is another command between opening the PDF and 'killing' it. Any help would be great - thanks in advance.</p>