If the referee is keeping the time on the field, the amount of added time is fairly discretionary.
Time is added for substitutions, assessment of injuries, removal of injured players, wasting time and any other cause.
Normally a few extra seconds would be found to allow plays as described in the OP to be completed.
Where the clock is kept on the scoreboard, when the horn sounds, time is up.
Hope this helps.