title: tkinter.TclError: invalid command name ".!toplevel.!label7"
body: <p>I have written a tKinter application for a Raspberry Pi.  I have a main screen and four Toplevel windows that are activated by buttons on the main window.  Each Toplevel window has a “Return to Maine Menu” button that destroys the Toplevel window so that the main window is displayed.  One of the Toplevel windows calls a recursive function that polls sensors attached to the Raspberry Pi and displays the data from those sensors on the screen.  The recursive function repeats ever second.  When I click the “Return to Main Menu” button on this Toplevel window, the window closes, but I get the following error message stream:</p>
  <pre><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File &quot;/usr/lib/python3.9/tkinter/__init__.py&quot;, line 1892, in __call__
      return self.func(*args)
    File &quot;/usr/lib/python3.9/tkinter/__init__.py&quot;, line 814, in callit
      func(*args)
    File &quot;/home/pi/Old_Marsh_Module.3.py&quot;, line 171, in Refresher
      lps5.configure(image = BP1_on_off)
    File &quot;/usr/lib/python3.9/tkinter/__init__.py&quot;, line 1646, in configure
      return self._configure('configure', cnf, kw)
    File &quot;/usr/lib/python3.9/tkinter/__init__.py&quot;, line 1636, in _configure
      self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
  _tkinter.TclError: invalid command name &quot;.!toplevel.!label7&quot;
  </code></pre>
  <p>From what I have been able to find on this and other websites, the problem seems to be caused when the window closes while the recursive function is still running. Is there a way to stop the recursive finction before the tK
  inter Toplevel window is destroyed?</p>