Have you tried using an END{...} block in the program? Just curious -- it's the first thing I would try, because it's the standard method for hooking into perl's shut-down procedure, but I've never tried it in a Tk app, and I don't know whether that raises issues.
If you did try it, it would be worthwhile to post your findings about that.