Bug 1028451 - Tweak shutdown to be testable and test it