But if the student has received his master way before his qualifying exam, is there other way to write the record that looks better?
First, the student doesn't get to write the record. The university writes the milestones that the student passes, specifically, which classes they took and with what grades, and which degrees they earned. (In some countries, the thesis itself also receives a grade, like a class.) At least in the US, intermediate milestones like finding an advisor, passing or failing quals, proposing or failing to propose a thesis, probation, suspension, termination, and even academic integrity violations are rarely recorded on university transcripts.
So, for example, if a student were asked to leave a PhD program after 2.5 years, for whatever reason, the transcript would show five semesters worth of classes, ending without the student earning a degree, because they didn't.
Many PhD students in this situation opt to switch to an MS degree program in their final semester, so that they can plausibly claim that they were just a masters student. (After all, in their last semester, they were just a masters student.) They don't have to explain why they left without a degree.
If the student already has a MS in their home department, earning a second MS in the same field is usually impossible. But another option is to switch to an MS program in a nearby field, for example, applied math or computer engineering or operations research instead of computer science. At least at my university, switching from a PhD program in department X to an MS program in nearby department Y is usually fairly painless, especially if you have a supportive advisor in department Y.
If even that is not an option, I'm afraid there's little one can do. Your transcript will end without a degree, and most people reading it will assume that (or at least wonder if) you left because you were forced out.