I've had this interesting siege battle very similar to yours before. However I haven't had the battle timer zero out on me before the 3-minute square timer did.
Can you clarify whether this was the last siege turn?
I have a feeling that the reason you occupied the city in your scenario was not because you locked the enemy out (which actually makes sense from a warfare point of view), but because it was the last siege turn, when the AI is left with the choice of either sallying out as a last ditch effort to save the city, or surrender the city without a fight.
The second choice makes sense to me because of pure RTW game mechanics. In this case, it wouldn't have mattered whether you were inside or outside the city walls, or if you were on the square or not. You could actually have a dozen skirmishers hiding in a forest outside, and if they survive when the battle timer zeroes out, you actually can take over a city garrisoned with a full stack!
But your scenario might be different, so that's why I'm curious.
Bookmarks