Added code to terminate parallel processes.