Is Perl capable of handling Windows messaging? I know that if you were writing a Windows app, you could just have a message loop and handle the WM_CLOSE message.
All Windows can (and must) handle Windows messages. If your Perl app has a window (using Tk, wxPerl, or whatever), then yes. Unfortunately, most Perl scripts don't have a window. (The console doesn't count because Perl doesn't manage that window.)