Tkinter intvar causing process to live on
<p>I realize there are many <a href="http://stackoverflow.com/questions/110923/close-a-tkinter-window">examples</a> of how to properly close a Tkinter GUI by calling the root.destroy() function. They work with my setup except I've determined that including a variable of type tkinter.intvar causes the gui process to live on even after I close the window. Here's a working example:</p>

<pre><code>import mtTkinter as Tkinter #special threadsafe version of Tkinter module, required for message windows. You can use regular Tkinter if needed 

root = Tkinter.Tk()
root.wm_title("KillmePlz")

nexusvar = Tkinter.IntVar()

def ClosebyX():
    root.destroy()

closebutton = Tkinter.Button(root,text='Quit',command=ClosebyX)
closebutton.pack()
root.protocol('WM_DELETE_WINDOW', ClosebyX)
root.mainloop()
</code></pre>

<p>On my machine if I remove the creation of "nexusvar", the Tkinter.IntVar, when I close the GUI the process also stops. If this variable is included as shown above, I see the process linger after the gui is closed. I don't think mtTkinter makes any difference.</p>

<p>Does anyone know why this might be happening?</p>

<p>Windows 7 64 bit, Python 2.7.12</p>

<p>UPDATE 9/20/16:
mtTkinter is the source of this problem. The solution below is for regular Tkinter module use. For solving this problem using mtTkinter see the following <a href="http://stackoverflow.com/questions/14073463/mttkinter-doesnt-terminate-threads">post</a> </p>

<p><code>nexusvar</code> isn't a child of <code>root</code>, so when you destroy <code>root</code> it doesn't know to destroy <code>nexusvar</code> as well - the two things are separate. You can set an <code>IntVar</code> to have <code>root</code> as a parent by supplying <code>root</code> to the constructor. <code>nexusvar</code> should then be able to destroy itself when <code>root</code> dies.</p>

python tkinter process