Handle process exitting nicely.