Yes, they could, but could they keep everyone in a city of millions in their houses though?
I don't see a major difference between nothing entering or leaving an apartment compared to entering or leaving the village / suburb.
Both will run out of food in a similar time span.