What happens if a presidential candidate passes away at the last second?
Each party has its own protocol for this scenario, but in neither case does the running mate automatically take over the ticket. (Congress could also pass a special statute and push back Election Day, giving the dead candidate’s party time to regroup.)
If John McCain were to die before the election, the rules of the Republican Party authorize the Republican National Committee to fill the vacancy, either by reconvening a national convention or by having RNC state representatives vote. The new nominee must receive a majority vote to officially become the party candidate.
If Barack Obama were to die before the election, the Democratic Party’s charter and bylaws state that responsibility for filling that vacancy would fall to the Democratic National Committee, but the rules do not specify how exactly the DNC would go about doing that.
And then there’s answers to all sorts of other scenarios such as death after the election but before the inauguration.