I have worked as a Warden in two elections for a precinct in Maine. We count the ballots before the polls open.
After the polls close we count the ballots left over plus
the ballots that have been marked and read by the machine.
This may sound usual but the two totals equal.
At the time the polls close we can account for all the ballots.
Sounds like a great system....should be universally adopted.