Rework PD terminate_process

- better validation of parameters
- don't try to terminate any process in a terminal state, not just
  >= TERMINATED
- log process state changes
- fix race where TERMINATED heartbeats could be received before
  TERMINATING state was set -- this resulted in the PD assuming
  a erroneous termination, and restarting the process!