It may depend on the command line and process name. People often get these two mixed up and wonder why the program doesn't show or kill what they thought should have been. Also swapped out processes or process that change their name can make it difficult to track.
I'm going to assume here your program doesn't have a PID file. That is actually the best way to track the process because some people might want two processes running (say test and dev, using different config files). Also your method assumes the process name is unique to your project.
For what you are trying to do, pkill is probably a better fit because you can just give it the process name without bothering with pidof. The problem with pidof is if you have multiple processes that match and you were expecting a single integer; you might break your script. Also if using pkill, then use pgrep as they have the same logic.
Something like:
#!/bin/sh
pkill processName
pgrep processName
if [ $? -eq 0 ]
then
sleep 3
pkill -9 processName
fi
pidof
already give you the PID? Why not use that withkill
directly instead of relying onkillall
?