improve process termination and add latency test