Avoid messing up terminal on exit or crash