Tweak shutdown to be testable and test it