in reply to closing window and running sub-routine

Well, the first problem is that you are missing a final brace on the anonymous sub.

I'd guess that you are using Perl/Tk? In that case, I'd use a callback of the form

my($dismiss) = $root->Button ( -text => 'dismiss window', -command => sub{ $message->destroy; command();} );

-Mark