Found it,
when io is set after popen use, it's easy to get the process ID and
then to correctly kill it during its execution.
#get the process id
IO.popen(cmd){ |pipe|
current_process = pipe.id # Saving the PID
pipe.each_line {|l|
puts l
}
#kill the process
Process.kill("KILL", current_process)
et voila.