Fixing firefox javascript error at startup and shutdown