Perl extensions are typically .pl or .pm right? .py is for python I think.
Anyway, you can kill a specified program in a Unix environment with something like:
system 'killall', 'some_program_name';
or
system 'kill', '-15', $pid;
if the variable $pid holds the pid of your program.
4
solved How do I stop a process running using Perl? [closed]