Presidential candidates spend millions of dollars and months—even years—rallying support for a nomination from their respective parties. At stake is the highest political office in the country.

But what if someone realizes they’re not into it anymore and decides, at a very late date, to drop out of the race?

The question has been circulating in media following the highly-publicized indiscretions of the two major-party presidential candidates. Democratic nominee Hillary Clinton was under investigation by the FBI for using a private email address for classified government business; Republican candidate Donald Trump has come under fire for controversial remarks about everything from newscasters to Muslims. If either elected to drop out of the race, it would cause a calamity within their respective party.

For Republicans, a hypothetical disappearance of Trump for reasons not due to health would have them looking at Rule 9 of the Republican National Committee policies. If a vacancy opened up, the GOP would have an opportunity to reconvene for a second convention or have the party name a new candidate. House Speakers, runners-up, or prospective vice presidents could all conceivably have a shot at the open slot, but the party is free to choose anyone and the states would retain the same number of delegates they had during the convention.

Similarly, the Democratic Party’s bylaws stipulate that a special meeting would be called by its chairperson to find a proper replacement. In both cases, the parties would hope the nominee would announce his or her intentions no later than September in order to find a suitable replacement. If they didn't, it’s possible Congress could take the unprecedented step of pushing back Election Day.

To date, no candidate from a major party has withdrawn or perished prior to the election. The closest historical parallel is James Sherman, William Taft's vice president and repeat running mate when Taft was seeking reelection. In 1912, Sherman died from kidney disease just six days before the general election. His name remained on the ticket, and the Republican Party decided to wait until the election was over to assemble and recruit a new vice president.

It was merely a formality, as Democrat Woodrow Wilson won the election. But it did have the curious effect of having voters submitting ballots for an official who had no chance at all of living up to his campaign promises, as Sherman was deceased.