Fixed bug in termination of subprocesses