Added more careful shutdown logic to some unit tests that run an executor.