How does Vanellope von Schweetz actually leave Sugar Rush in Ralph Breaks the Internet when it was quite dramatically established in Wreck-It Ralph that she can't leave Sugar Rush at all?
She couldn't leave the game in Wreck-It Ralph because of Turbo messing with her code. This made her a glitch, and glitches can't leave the game.
King Candy: Then gamers can choose the racer's avatar. And when they see her glitching and then get glitching in just being herself... They'll think our game is broken. We'll be put out of order for good. All my subjects will be homeless. But there's one who cannot escape because she's a glitch.
Sour Bill: Vanellope was a racer until King Candy tried to delete her code!
Ralph: Tried to delete her code? So that's why she's a glitch!
However, after Vanellope crosses the finish line, the game resets and she's no longer a glitch.
Sour Bill: He'll do anything to keep her from racing. Because if she crosses the finish line, the game will reset and she won't be a glitch anymore!
She chose to maintain the ability zip around like a glitch, but she is fundamentally no longer a glitch, so she can leave the game. (Either that, or this is actually her in-game special ability.)
And, as @BinaryWorrior mentioned in the comments, we see Venellope leave her game at the end of Wreck-It Ralph, to attend the wedding of Fix-It Felix and Calhoun:
See also this answer on Movies & TV Stack Exchange, which parts of this answer were based on.