How to gently kill Firefox process on Linux/OS X
In Mac OS X, you could use AppleScript to close it (adjust the application name as necessary; I don't have FireFox installed to test):
$ osascript -e 'tell application "FireFox"quitend tell'
This should trigger the same event that the Quit menu command triggers, so FireFox should shut down cleanly.
Obviously, this won't work in Linux.