LV Vet asked in the comments about the procedure for impounding voting machines and counting votes. (See next post.)
I'm not a lawyer (thankfully), and the New York State Election Law [pdf] is 516 pages long. With that caveat, here's what appears to be the money quote on "recanvassing" or basically making the "final count":
§ 9-208. Provisions for recanvass of vote in every election district in
the state; procedure in case of discrepancy.
1. Within fifteen days after each general, special or primary election, and within seven days after every village election conducted by the board of elections at which voting machines are used, the board of elections, or a bipartisan committee of or appointed by said board, shall in each county using voting machines, make a record of the number on the seal and the number on the protective counter, of each voting machine used in each election district in such general, special or primary election, shall open the counter compartment of each of such machine, and, without unlocking such machine against voting, shall recanvass the vote cast thereon . . .
In the initial canvass, on election night, the voting machine is locked against voting and the totals are read off and recorded. Then the machine is sealed. (§ 9-102)