in reply to Re^5: Cannot catch ALRM signal for timeout
in thread Cannot catch ALRM signal for timeout

kill $scheme_pid;

You probably meant something like

kill INT => $scheme_pid;

As you have it, kill would try to send the signal number $scheme_pid to no processes — so nothing happens, effectively...

As a result, your code hangs in the implicit wait behind close SCHEME, because the child process is still alive.