About law 21.17, here we have a scenario:
In open play and the time is up. What about the situation when neither the ref and AR don’t know if the ball is grounded or not. (No TMO in that pitch)
Should we blow the whistle to finish the game or make the last scrum call, attacking team throw in?
Law 21.17 says "If there is any doubt about which team first grounded the ball in in-goal, play is restarts with a five metre scrum.."
In your example we don't know if the ball as grounded or not, assuming the ball was taken into in-goal by the attacking team, and we can't see it grounded, then the call would be held up, which would also result in a five metre scrum.
So now we have to look at the law on time.
A half ends when the ball becomes dead after time has expired unless:
A scrum, lineout or restart kick following a try or touchdown, awarded before time expired, has not been completed and the ball has not returned to open play. This includes when the scrum, lineout or restart kick is taken incorrectly.
The key phrase in this law is "awarded before time expires". Since time had already expired in your example, the scrum was awarded after time had expired, so the game ends.
Hope that answers your question.
The Rugby Ref