Welcome to Smogon! Take a moment to read the Introduction to Smogon for a run-down on everything Smogon, and make sure you take some time to read the global rules.
When Primal Groudon is the player's last pokemon and attacks a pokemon holding a red card the sun disappears even though it doesn't actually get switched out.
http://replay.pokemonshowdown.com/randombattle-187200766 (turn 19)