# window_close_demo.py
import tkinter as tk
from tkinter import messagebox

def on_close():
    if messagebox.askokcancel("Quit", "Do you really want to quit?"):
        root.destroy()

root = tk.Tk()
root.title("WM_DELETE_WINDOW Example")

# Override the window close button
root.protocol("WM_DELETE_WINDOW", on_close)

root.mainloop()