What you need to do is trap the signal that is sent when the program exits. I can't remember off the top of my head what that is called on Windows - but if you
print keys %SIG you should be able to tell.
Once you get it figured out which signal you need to trap, put something like the following in your code (before the MainLoop).
$SIG{KILL}=sub {
kill 15 => $kid;
exit;
};
Note, you will also want to read through
perlipc for more info regarding trapping of signals.