DefaultLegacyHooks: add a convenience constructor
Add regression tests for shutdown behavior

The tests check three scenarios:

* ij.ImageJ#quit() with exitWhenQuitting set to false
* LegacyService#dispose()
* LegacyUI#dispose()

A separate integration test will be needed to test ij.ImageJ#quit() with
exitWhenQuitting set to true, since surefire and failsafe cannot support
tests that result in System.exit being called.