Improve hard shutdown procedure to reduce risk of dropping jobs. #623

See #623.