How can the AP call US midterm races just as the polls close?

Al Jazeera is using Associated Press data to determine midterm election race winners.

How can the AP call US midterm races just as the polls close?
Al Jazeera is using Associated Press data to determine midterm election race winners.