Maybe remove the pid file before killing, not after? If it resists our best attempts at killing. including -9, that would be a different bug, and leaving a pid file would be useless anyway? Just a guess.