The following code, when the user hits <Alt+F4> or clicks the little close
gadget on your window, destroys the TkRoot singleton, so everything below
the first Tk.mainloop won’t work:
bgerror failed to handle background error.
Original error: c:/ruby/lib/ruby/1.7/tk.rb:358:in `call’: return from
proc-closure
Error in bgerror: can’t invoke “toplevel” command: application has been
destroyed
Witness my feeb attempt to tell the Tk.mainloop to gracefully exit instead
of destroy everything inside itself. I tried to bind to the Destroy event.
We may presume that the Destroy event itself takes down the Tk context. In
this case, maybe there is some other event I can bind to, or some other
binding site.
I would prefer, for elaborate & irrelevant reasons, not to just add a
stinkin’ button one can click on to call the Tk.quit. And experiments with
Tk.callback_break likewise bomb. Experiments opening another window, so the
first Tk.mainloop would still feel useful when the canvas goes down, also
failed.