title: Close Python IDLE shell without prompt
body: <p>I am working on a script (script A), that needs to open a new Python IDLE shell, automatically run another script (script B) in it and then close it. The following code is what I use for this purpose:</p>
  
  <pre><code>import sys
  sys.argv=['','-n','-t','My New Shell','-c','execfile("VarLoader.py")']
  import idlelib.PyShell
  idlelib.PyShell.main()
  </code></pre>
  
  <p>However I can't get the new shell close automatically. I have tried adding the following to script B but either it doesn't close the new shell or a windows pops up asking whether I want to kill it.</p>
  
  <pre><code>exit()
  </code></pre>
  
  <p>.</p>
  
  <pre><code>import sys
  sys.exit()
  </code></pre>