title: Tkinter window will not close upon clicking a button
body: <p>(I apologize for the naive question)</p>
  
  <p>I have a window that pops up that allows a user to select two months as a starting point and end point for data collection. </p>
  
  <p><a href="https://i.stack.imgur.com/Mh2Ba.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mh2Ba.png" alt="enter image description here"></a></p>
  
  <p>The events that occur with the click of the 'OK' button are to return a list and dictionary of the months in between the selected range, and to notify the user of their selected range. However, I would like this window to close after clicking 'OK' as well. The events are under the <code>callback</code> function. I cannot make <code>root.destroy</code> reachable.</p>
  
  <p><em>All the code that is involved is here. My function <code>callback</code> is towards the bottom:</em></p>
  
  <pre><code>from tkinter import *
  
  startDate = 'Dec 16'
  now = datetime.now()
  endDate = now.strftime('%b %y')
  start = datetime.strptime(startDate, '%b %y').date()
  end = datetime.strptime(endDate, '%b %y').date()
  cur_date = start
  range_months = []
  
  while cur_date &lt; end:
      cur_date += relativedelta(months=1)
      range_months.append(cur_date)
  
  range_months = [month.strftime('%b %y') for month in range_months]
  dict_months = dict((month, pd.to_datetime(month, format='%b %y')) for month in range_months)
  
  root = Tk()
  #root.withdraw()
  root.title("Select your Month Range")
  
  # Setting up Grid
  mainframe = Frame(root)
  mainframe.pack(pady=50, padx=50)
  Label(mainframe, text="Select Start Month").grid(row=1, column=1)
  Label(mainframe, text="Select End Month").grid(row=1, column=6)
  
  # Creating two Tkinter variables to obtain user input from the drop down menus
  tkvar_start = StringVar(root)
  tkvar_end = StringVar(root)
  tkvar_start.set('Jan 17')  # Setting a default option
  tkvar_end.set(endDate)
  
  start_popupMenu = OptionMenu(mainframe, tkvar_start, *dict_months)
  end_popupMenu = OptionMenu(mainframe, tkvar_end, *dict_months)
  start_popupMenu.grid(row=2, column=1)
  end_popupMenu.grid(row=2, column=6)
  
  
  def callback_range():
      print('The range is from %s to %s' % (tkvar_start.get(), tkvar_end.get()))
      list_of_month_keys = list(dict_months.keys())
      import itertools
      range_dict_months = dict(itertools.islice(dict_months.items(), list_of_month_keys.index(tkvar_start.get()),
                                         list_of_month_keys.index(tkvar_end.get()) + 1))
  
      return list_of_month_keys, range_dict_months
  
  
  button = Button(mainframe, text = "OK", command = callback_range)
  button.grid(row=3, column=23)
  
  root.mainloop()
  list_of_month_keys, range_dict_months = callback_range()
  </code></pre>
  
  <p><strong>How can I make <code>root.destroy()</code> reachable in my function <code>callback</code>, while still returning <code>list_of_month_keys</code> and <code>range_dict_months</code>, in order to additionally close this window upon clicking 'OK'?</strong></p>