Fixes #3175 - process exiting is handled more carefully