Use pkill instead. There is also a pgrep.
This will do what you want, and how much simpler can you get?
pkill firefox
Using the -9 option to pkill would be what you currently do; however, avoid SIGKILL:
Do not use this signal lightly. The process will not have any chance to clean up. It may leave behind orphaned child processes, temporary files, allocated locks, active shared memory segments, busy sockets, and any number of other resource state inconsistencies. This can lead to surprising and hard to debug problems in the subsequent operation of the system. [wlug.org]
And:
By the way, this is one reason you should not routinely use
SIGKILL. SIGKILL should only be used when a process is
hung and cannot be killed any other way. If you use a
SIGTERM or SIGINT in the python script, you will see that
mplayer WILL leave the terminal in a USABLE state. If you
routinely use SIGKILL programs do not have a chance to
clean up anything and can adversely affect your whole
system in some situations.
SIGTERM is the default signal sent by the kill shell command.
SIGINT is the signal sent from a terminal interrupt (control-C). [debian.org]