in reply to how to terminate a program?

Assuming you have the process id of the process you want to terminate in the variable $pid:
kill 15, $pid and kill 0, $pid and sleep 1 and kill 0, $pid and kill 2, $pid and kill 0, $pid and sleep 1 and kill 0, $pid and kill 1, $pid and kill 0, $pid and sleep 1 and kill 0, $pid and kill 9, $pid and kill 0, $pid and sleep 1 and kill 0, $pid and die "Help, can't kill the process";
That would try to kill the process sending it SIGTERM, SIGINT, SIGHUP and SIGKILL, in that order, and with a 1 second delay in between. The kill 0 will fail if the process went away, terminating the construct. Note that this will fail to die with the message if it can't kill the process if the process changed UID.

This might not do the right thing if after sending it a signal, the process doesn't die right away, but dies while the killing program sleeps, and another process, with your UID, is born, and getting the same PID as the process you're trying to kill.

If you happen to have imported POSIX::sleep, replace sleep with CORE::sleep.

If the process to be killed takes more than a second to clean itself up, it might be killed by the wrong signal.

According to perlport, the above will not work on Mac OS nor on RISC OS, and won't give the process to shutdown cleanly on Windows.