When the polls close on Election Day and no more voting is allowed, the election judge at each polling place has poll workers seal all the ballot boxes.
The boxes are sent to a central vote-counting facility. This is usually a government office, such as a city hall or county courthouse.
There, if paper ballots are still used, election officials manually read each ballot and add up the number of votes in each race.
Where punch-card ballots are used, election officials count the ballots by hand, then run them through a mechanical punch card reader, which prints out a tally.
For absentee/mail-in ballots, they're first cross-checked against voter registration records, to ensure there's no fraud taking place.
On Election Day—but never before—state election officials count the mail-in ballots, and add the tally to the ballots cast in-person.
With newer, fully computerized voting systems, the vote totals are transmitted automatically, or via removable digital media, to the central counting facility.