Election Day (Part 2) - S7-E17
Trivia: The election originally ended with Arnold Vinick as the victor. But in light of John Spencer's death (and by necessity, Leo's), the writers felt it would be too emotionally taxing on the audience for Santos to lose both his running mate and the election.
Suggested correction: The writers were not certain if they wanted Vinick or Santos to win, but it was not decided by John Spencer's death. They shot the scene in the thirteenth episode with John Spencer, indicating that it was decided well before his death that they wanted Santos to win. The direct quote "it would be too emotionally taxing on the audience for Santos to lose both his running mate and the election" is true, but said in the context of a decision being made independent of the death and subsequent character death.