There are several times in a trial when I might ask the judge for a no contact order, to sequester witnesses, or to prohibit witness contact during a break or recess in the trial.
I have a fairly standard format for rape and child abuse cases. These in my experience are the cases where the opportunity for witness contamination is at its apogee. Oftentimes you are arriving on the scene too late as the defense counsel because most of the damage has already been done. However, you should still be attempting to minimize damage. For the moment though I wanted to focus on what happens in trial when there is a break in the trial and a witness is still on the witness stand either for their direct, their cross-examination, their redirect, or might be back for rebuttal. And this point works both ways — for defense and for government.
My personal belief is that once someone has begun their testimony no-one should talk to them and they should be told by the judge not to talk with anyone, including talking with the lawyer who called them. I always ask that of the judge when a prosecution witness is involved, and I always tell that to my own witnesses if it happens to us. There are too many ways subtle and not so subtle that a person can respond to the "how am I doing question," for example.