Add a test for LegacyHooks shutdown hooks

All it does right now is verify that the hooks were indeed called, once
each. It does not check whether they were called in the right order. And
it does not check whether returning false with any of them will
terminate the shutdown sequence as it should.