Bug 812608 - Part 2b: More robust shutdown logic; r=rnewman