How to run code when the tkinter window is killed code example Example: python tkinter close gui window from tkinter import * root=tk.Tk() root.destroy()