title: The grid Button command executes but does nothing in the function I want
body: <p>I'm making a game and two buttons should appear on the ranking grid. The options are: If you want to play a new game or end the game. I tried this way:</p>
  <pre><code>import tkinter
  from tkinter import *
  import tkinter as tk
  
  class Ranking:
      def __init__(self) -&gt; None:
          self.partidas = []
  
  def agregar_partida_terminada(self, partida):
      self.partidas.append(partida)
      self.calcular_promedio()
  
  def calcular_promedio(self):
      for partida in self.partidas:
          for jugador in list(partida.keys()):
              lista_cantidad_de_intentos = [partida[jugador]['intentos'] for partida in self.partidas]
              partida[jugador]['promedio'] = sum(lista_cantidad_de_intentos) / len(lista_cantidad_de_intentos)
  
  def generar_ranking(self):
      self.raiz = tk.Tk()
      self.raiz.title(&quot;Ranking&quot;)
  
      # self.raiz.configure(bg=&quot;#fff&quot;)
  
      valores_tabla = [['J', 'C', 'T', 'P']]
      ultima_partida = self.partidas[-1]
      for jugador in ultima_partida:
          valores_fila = [jugador]
          for campo in list(ultima_partida[jugador].keys()):
              valores_fila.append(ultima_partida[jugador][campo])
          valores_tabla.append(valores_fila)
  
      for indexFila in range(len(valores_tabla)):
          fila = valores_tabla[indexFila]
          for indexCol in range(len(fila)):
              Label(self.raiz, text=fila[indexCol]).grid(row=indexFila, column=indexCol, sticky=NSEW)
      Ranking.end_game(self)
      Ranking.new_game(self)
  
      self.raiz.mainloop()
  
  def close_ranking(self):
      self.raiz.destroy()
  
  def end_game(self):
      End_Game = tkinter.Button(self.raiz, text=&quot;Terminar partida&quot;,
                                command=lambda: [True, self.close_ranking()])
      End_Game.grid(row=4, column=0)
  
  def new_game(self):
      New_Game = tkinter.Button(self.raiz, text=&quot;Jugar nueva partida&quot;,
                                command=lambda: [True, self.close_ranking()])
      New_Game.grid(row=4, column=3)
  </code></pre>
  <p>And the execution of the button must be moved here and then close the grid:</p>
  <pre><code>...
  
  from ranking import Ranking
  
      if ranking.end_game() is True:
  
          finalizar_juego = True
  
      elif ranking.new_game() is True:
  
          finalizar_partida = False
  ...
  </code></pre>
  <p>But when i press any button the grid close and show me this error:</p>
  <pre><code>_tkinter.TclError: can't invoke &quot;button&quot; command: application has been destroyed
  </code></pre>