Ricardo, a Referee of youth players, asks:
When is the referee allowed to stop the play? Can he stop the play when time expires but the ball has already been kicked and is in the air going towards goal?
Your two questions are slightly different. When is the Referee allowed to stop play? By Law and tradition, anytime he or she feels it is necessary. The stoppage could be for a specific reason or for no reason not specifically provided for in the Law. Sometimes play stops despite the Referee. For example, technically, play stops when the ball leaves the field and there is no specific action the Referee is required to take to implement or authorize the stoppage. Nowhere in the Law does it say that the Referee stops play when the ball leaves the field but, on occasion, some action is needed to remind players that the ball has left the field (particularly if they keep on playing it) and, indeed, in such cases a whistle sounds solely to get their attention.
Other times, the Referee has discretionary authority to stop play. The most common example here is the commission of an offense specified by the Laws of the Game — fouls, misconduct, offside, etc. First of all, the Referee has to recognize that an offense has occurred, then decide that it is not trifling, then decide not to apply advantage, and then, finally, whistle play to stop. Just as with a stoppage due to the ball leaving the field, it is not the whistle which forces the stoppage but the decision that play must be stopped. Most times, the whistle merely marks that the decision has been made but happens so quickly following the decision that there is no appreciable time between the two. Sometimes, this is not the case: advantage is often an example because, until the Referee has had a chance to determine that the advantage has been achieved and maintained for several seconds, there could be at least a short while before a whistle is blown or the actual advantage signal is made.
Now we come to your second question. Every match has a specified length of half. Law 7 (Duration of the Match) sets this at 45 minutes. Although it can be less time for certain categories of players as determined by the competition authority, but it is always a specific number of minutes. That time may be extended officially by the need to conduct a penalty kick despite time ending. The time may also be extended due to time lost as a result of excessively lengthy delays but the Referee is required to carefully monitor such situations and decide, to the nearest whole minute (rounded down) how much time must be added. The period of play (first, second, or any subsequent additional period to break a tie), then, is an exact measurement.
Unfortunately, there are many so-called rules or notions about how Referees are supposed to mark when a period of play is over. By Law, no such rule exists or is authorized with the exception of the penalty kick in extended time. Myths abound. The Referee is supposed to wait until the ball is in the middle third before signaling the end of a period. The Referee is not supposed to signal the end of a period if either team is attacking the goal (a version of this is that it applies only if the team which is behind has the ball). The Referee is not supposed to signal the end of time if play is already stopped — which is taken to mean that the Referee must always perform the restart (goal kick, kick-off, free kick, etc.) before whistling the stoppage due to time expiring (apparently, this often gets the additional requirement that, after the restart, let the players play for at least a little bit).
Every Referee has a theory here, or was told “this is how it is done” in their entry level class, or was told by an assessor, or heard it on the grapevine, or from a TV commentator (!). None of them is correct … or all of them are correct (though some are sillier than others). Decide for yourself but, whatever you do, do it consistently regardless of what’s going on at the moment. Time is up when it is up but, in a match governed by the Laws of the Game, no one knows for sure when this is except for the Referee and, as the Referee, you must be able to justify to yourself whatever you come up with. We will advise one thing further and that is never to talk to anyone about “your rule” because none of them hold up to challenge. Just smile mysteriously and simply declare that time was over.
One serious problem in all this is that the players in their current game will get all bent out of shape if the Referee does (or does not) whistle the end of a period when they think it should be — which is why they frequently ask how much time is left and which is why you should not answer this question except in the most general way.