Instead of closing the filehandle, how about killing the subprocess with kill()? I have no idea if that works on Windows but it's what I'd try if I had this problem on Linux.
tx, samtregar but "closing the filehandle" was only my first idea to open and close that pipe as i want only by clicking on the buttons.
But it dont seems so easy. I can open the pipe easy but its not possible in this way to close the process... It seems to be a much more complex process :-(