I think you need to avoid this if-then check for stopping; otherwise, you'll fail to try to stop when the PID file is missing.