fixed bug in subprocess cleanup