Instead of child.wait() use child.close()