Strip terminal escape sequences when unnecessary.