The referee does not stop a rally to penalize anyone. The warning or foul is given once the rally is over.