Fix critical problems with quitting

DO NOT MERGE YET.

Depends on https://github.com/imagej/ij1-patcher/pull/29 getting merged and a new `ij1-patcher` released.

Still needs regression tests as well as manual testing. But the approach is fully fleshed out—comments welcome.