Time is up when time is up. Doesn't matter where the ball is.
So if there are 5 minutes of extra time and a player is fouled in the penalty area at 94:50 they won't have enough time for a penalty? Okay then. Usually if a dangerous attacking play is taking place they don't end the half.