How many people will vote in a county is super predictable. There are only 2 reasons to run out of ballots
Turnout is unusually high (Not likely).
You printed less ballots than you needed (Really likely).
That's it, that's the end of the reasons. You can literally print the same number of ballots for the last similar election and you'd have a good chance of having enough at least for most of the voting with some good early indicators that you need more at the beginning of the election. To run out 2 hours into an election shows you didn't even print as many ballots as you did for the last major election.
The math for how many ballots to print is "last similar election * (county growth percentage * last election turnout percentage) * 1.05". That's it. That will cover enough ballots for pretty much any election except for an extreme one where turnout is WAY higher than what could be predicted.
That math actually results in not having enough ballots in areas with more voter suppression if they actually turn out for the next election. The correct number of ballots is 105% of the number of registered voters so everyone can vote in any given election, with some spares for mistakes.