You are probably running into the common problem where you are actually getting the $pid of the shell, from fork(), which is actually running your desired forked program. You need to kill the shell and all it's descendants. Try:
use Proc::Killfam;
killfam 9, $pid;