Bug 837539 - Fix crashes due to premature deinitialization. r=rjesup,bgirard