how to add exit function on press of window close button in tkinter code example Example: python tkinter how to close a window root.destroy()