(Mandel Ngan/Agence France-Presse via Getty Images)

Benjamin Franklin once wrote that “in this world, nothing is certain except death and taxes.”  He probably should have added one more thing: Incumbent politicians will always find a way to ensure their reelection.

Partisan redistricting has long been a cornerstone of incumbents’ strategy to stay in power. Nowadays, few question how congressional districts are engineered (or “gerrymandered”) for partisan and incumbent advantage.

Take Virginia’s 7th Congressional District. From the time of its creation in 1935 until today, three Democrats (1935-1971) and five Republicans (since 1971) have represented it. Over those nearly 80 years, none of these eight congressmen ever lost a reelection bid — until last week, when House Majority Leader Eric Cantor fell to David Brat in a Republican primary.

Cantor’s defeat shows how times have changed. There are no longer any completely safe seats. Gerrymandered districts can eliminate the risk of a successful Democratic challenge, but there is nothing to stop primary challenges from tea party candidates.

The good news for Republican incumbents is that there’s a simple way to change the game and tame the tea party threat: the top-two primary.

In the traditional closed-primary system, each party holds a separate primary election to determine a single candidate who then advances to compete in the general election.  A top-two primary system differs in that there is only one primary election with candidates from all parties, the top two of whom then compete in a runoff general election.

Advocates of the top-two primary have long argued that this system would change the sort of politician who is elected to public office, allowing those with more centrist views to prosper because they don’t necessarily need to get the most votes from any one party to qualify for the general election. That may turn out to be true but there is little evidence of such a moderating effect in states such as California and Washington that have adopted the top-two primary system.

Nevertheless, it’s easy to imagine how a top-two primary might have saved Cantor. Although he got fewer votes than Brat among registered Republicans, Cantor probably would have beaten Brat among non-Republican voters. It’s impossible to know whether these non-Republican votes would have been enough to push Cantor past Brat but, if so, the outcome probably would have been Democrat Jack Trammell in first place, followed by Cantor in second and Brat in third. (Trammell would have gotten the Democratic vote, while Cantor and Brat would have split the Republican vote.)  Trammell and Cantor would then have faced off in the general election, with Cantor very likely to have won.

If the 7th District were an even more conservative district, Brat and Cantor might have taken first and second place overall. Cantor would benefit from a top-two primary in this case as well, because he would be able to draw independent and Democratic votes in the general election.

Critics of the top-two primary argue that it creates problems, such as the confusion that voters can feel when presented with so many candidates from across the political spectrum.  Yet even this weakness naturally plays into the hands of incumbents, as voters are more likely to recognize their names in a crowded field.

To all the Republican incumbents fretting over their futures, I have this simple advice: Get your state to adopt a top-two primary.  You’ll never have to worry about early retirement again.

David McAdams is a professor of economics at the Duke Fuqua School of Business and the author of “Game-Changer: Game Theory and the Art of Transforming Strategic Situations.”