cpu-exec: Move halt handling out of cpu_exec()