Both the Palette XCMD and the Picture XCMD -- and now the Movie XCMD -- will send a message to the current card signaling that a window is closing. These messages are, respectively, "closePalette","closePicture", and "closeMovie".
The parameters sent with the message identify the window that is closing: The first parameter is the window's name and the second parameter is the window's ID (window IDs are new in HC 2.1). The message is sent when the window closes, either via a click in a closebox, or by executing a "close window" statement.
Stack designers can define a "closePalette", "closePicture", or "closeMovie" handler to take care of any cleaning up or updating when a window is closed.
HERE IS ONE RESTRICTION- Don't try to close the window again within a closePalette, closePicture, or closeMovie handler. The script can STILL refer to the window, for example, getting (or even setting) the window's location. The script can also close other windows -- but HyperCard will crash if the script tries to close the window (e.g., close window id (the param of 2)).