And although it seems some sectors in the PA political media have pushed for something akin to having that happen - i.e., a "resign to run" provision for PA, there are only 5 states that actually have that and PA is NOT one of them for state-wide offices.
In fact, the City of Philadelphia DOES have such a rule and the past couple months, we have had 4 City Council members and our City Controller resign their seats to run for next year's mayor's race.
But see this article from back in 2010 -
Reform advocates call for resign-to-run law
Updated: May. 17, 2010, 4:31 a.m.|Published: May. 17, 2010, 3:31 a.m.
By Jan Murphy | jmurphy@pennlive.com
No matter what happens in Tuesdays primary none of the losing gubernatorial candidates will be without a job on Wednesday. All of them, including the two winning candidates, still can count on their public-funded paychecks that they collect from the elected offices they currently hold.
Republican Tom Corbett has his attorney generals job and his GOP primary challenger, Sam Rohrer, has his state House seat. On the Democratic ballot, Dan Onorato has his Allegheny County's executive post; Tony Williams, his state Senate seat; Jack Wagner, his auditor general's job; and Joe Hoeffel, his Montgomery County commissioner seat.
But some government reform advocates don't think that is fair to taxpayers. "You can't claim you're working a full-time job on behalf of the people while simultaneously running a full-time campaign on behalf of yourself," said Eric Epstein of RockTheCapital.org.
Tim Potts of Democracy Rising PA said he views getting elected to an office as a contract with the voters. "They gave you a vote in exchange for you to serve [the full term of office]," Potts said. "If you do not serve [the full term], you owe them a better explanation than, 'I just want to take another step to the next rung on the political ladder.' "
(snip)
https://www.pennlive.com/midstate/2010/05/reform_advocates_call_for_resi.html
So in the (very) unlikely circumstance that Shapiro doesn't win, he'll still be AG for another 2 years. What will need to happen though, is that assuming he wins, there will have to be some kind of appointee to fill the term out until a special election is called and that would be up to the governor regarding when (after some set minimum days after the vacancy).