To quit Firefox
Components
.classes['@mozilla.org/toolkit/app-startup;1']
.getService(Components.interfaces.nsIAppStartup)
.quit(Components.interfaces.nsIAppStartup.eAttemptQuit)
To restart Firefox
var boot = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup);
boot.quit(Components.interfaces.nsIAppStartup.eForceQuit|Components.interfaces.nsIAppStartup.eRestart);
Additional Useful Flags
eConsiderQuit : Attempt to quit if all windows are closed.
eAttemptQuit : Try to close all windows, then quit if successful.
eForceQuit : Force all windows to close, then quit.
eRestart : Restart the application after quitting. The application will be restarted with the same profile and an empty command line.