In that case, the code you saw was probably long and complicated by a requirement to obtain the necessary privileges (I think) to be able to shut down other processes.

My question is why do you want to terminate other processes?