After looking at dostrander's code and my code again I realize that in neither case would the pidfile or the lockfile be removed if the call to start-stop-daemon is successful. It might be better to remove them before calling start-stop-daemon. But after checking that the PID is correct.
if [ $(sed -n '1p' < $PIDFILE) == $(pidof -x $NAME) ]; then
rm -f $PIDFILE
rm -f $LOCKFILE
fi
start-stop-daemon -K -q --retry=TERM/30/KILL/5 -n $NAME
RETVAL="$?"
printf "RETVAL is $RETVAL.\n"
[ "$RETVAL" = 4 ] && return 4