Dying in office won't produce mayhem. We have a well established process for that. The VP takes over and fights with Congress over who gets appointed as the next VP. The only drama will be who fills that role.
Dying just before the election? Now that will be a clown show. If the vacancy happens after the party convention the ballots likely wouldn't be able to be changed. However, as you likely know we are not voting for President and VP directly, we are voting for a slate of Electors pledged to the candidates. Many states bind those electors to vote according to the popular vote, and those states would need to pass quick laws changing that process.
If it's the winning side whose candidate bites it, there needs to be a ton of coordination to all this. Because there is still a process to counting those EC votes. If some votes come in for the deceased candidate at the top of the ticket and some don't, they will likely be counted separately and as a result no one would technically have the majority.
We do have a weird way to resolve that, though: if the EC has no majority, the House votes on the President and the Senate votes on the VP. But the House vote has an additional wrinkle, in that each State's delegation gets one vote. So, all 50+ of California's members get 1 vote, and Wyoming's Lone member also gets a vote. The math there favors the Republican candidate, even if Democrats control the House.
It could also result in the Republican choice being President while the Democrat becomes VP, which would make for the world's most awkward Peformance Reviews.