Fixed problem with the process kill function

The killpid function stopped everything when the process was killed. That
prevented it to remove the pid file and breaked everything.

Wrapped the kill call arround a test to prevent that behaviour.