Well, for starters, he'll need to fight the Elite 4 and Champion before he can formally gain the rank of Pok?mon Master. That essentially means that they can have Ash win the league, lose to an Elite 4 member, then have him challenge another league, beat that league, beat the first E4 member but lose to the second one, and so on and so forth until he finally manages to beat the champion. Don't forget, DP enunciated this part of the goal, and I don't think they'd bring it up if they weren't going to have Ash win the league.
And for the record, having him win a league won't automatically mean an end to the franchise. Don't forget, even after Goku won the Tenkaichi Budokai, the franchise didn't end, we got Dragon Ball Z, then GT, and then Super. Heck, as another user pointed out, Yu-Gi-Oh has the main character being allowed to win, and he doesn't end the show there. And as a matter of fact, Digimon replaces its main characters without much loss. And besides, even Pok?mon Special managed to pull off replacing main characters without impacting sales, even characters who WERE iconic such as Red.
And personally, if having Ash leave is the ONLY way he can be allowed to actually achieve his goal, I'd take it (the entire POINT behind having a goal is to accomplish it).