def on_closing(): if messagebox.askokcancel("Quit", "Do you want to quit?"): root.destroy() sys.exit()