As a preschool teacher, I would provide a lot of social coaching and try to move the children through the moment with empathy for both his anger AND the other child's feelings. This will be long, but since you asked, here's a script of what this might look like. (I'm adding generic "Tommy and Suzy" for clarity)
Tommy: You idiot! Go away from me!
Teacher: Wow, I see two kids who are pretty upset.
Suzy: Teacher, Tommy said I was an idiot!
Teacher: Yes, I see two kids who are really mad. (Still describing what I see.) Suzy, what happened? (I'm asking Suzy first, because she is less upset, not because she's 'the victim'. )
Suzy: I wanted to play with Tommy and he called names.
Teacher: Tommy, can you tell me what happened?
Tommy: I told Suzy to go away but she won't and she's not leaving me alone.
Teacher: So let me see if I have this right: Tommy, I understand you wanted to play by yourself. Suzy didn't let you and you got mad and called her a rude name. Is that correct? (recapping so that we are all on the same page and I know *I* didn't miss anything)
**Kids nod.**
Teacher: Suzy, did you like that Tommy was upset and using angry words with you?
Suzy: No.
Teacher: Then tell Tommy that.
Suzy: Tommy, I don't like when you use mean words at me. (they need tons of coaching at this, by the way)
Teacher: Tommy, did you hear what Suzy told you, that she doesn't like how you spoke to her?
Tommy: Yeah, but she wouldn't leave me alone.
Teacher: That's true too. Do you want to tell Suzy about it? What could you say in a friendly way?
Tommy: (either on his own or with coaching) Suzy, I don't want to play with you/ I don't want company right now.
Teacher: Suzy, did you hear what Tommy is telling you?
Suzy: But I want to play with Tommy.
Teacher: I understand this. You can say: "Tommy, I want to play with you when you are ready for company." This way he'll know.
Suzy: (repeats request)
This seems long and a bit pedantic, but this is what kids need- for everyone's emotions to be acknowledged and given a ton of social coaching. At this point, I would see if "Tommy" was ready to go back to what he was doing (with support from me to help Suzy understand she needed to leave him alone) or if I felt offering some quiet time in a cozy corner for Tommy was a better choice. I always had one or two spaces in my classrooms for independent, solo play, where kids could go to be alone. (we call them 'one player' areas) If Tommy was in a pretty grumpy mood, I'd invite him to go play in the cozy corner until he was ready for company. I remind children that the cozy corner is a place for just one person and that I will help them to be left alone if need be.
The Cozy Corner is a place for kids who need to be alone, to calm down, to rest... it's not a punishment. If we have a lot of hurtful words going on, perhaps we try the Cozy Corner first; if the language continues, then I get more direct and have a child sit in time out. I'm pretty clear that these words are 'mean and hurting words and they hurt just as much as hitting'. We pretty much reserve Time Out for aggressive hurting behaviors,spitting, or flat-out digging-in-the-heels noncompliance to directions; Time Out for hurtful language is also okay.
And as a mom, if my son is was using this language, I'd send him to his room until he was ready to use better words and was ready to be with company. He knows that this means his language/behavior is not welcome in the common areas of the house. "Come back when you are ready to talk about this in a calm way".