Broken Saints: despite all the suffering they have had to go through, each of our "broken" heroes is healed in the end, the men by the power of Shandala's love, Shandala by the power of theirs, and the world is saved.
The two main characters in There she is!! go through a number of tribulations before they get to their happy ending.
In the interactive poem Today I Die, this is used as a metaphor for overcoming depression. The protagonist must swim with a boulder tied to her waist.
Very few cosmichorror stories have happy endings, but Ruby Quest is one of those few. The protagonists have to face mutations, monstrous abominations, unspeakable evils from the beginning of time, and trying to escape from a mysterious facility where they have been trapped for over a year already, with several dozen failed escape attempts. The main characters get the happy ending they deserve, some of the others don't.
In addition, how the happy ending is earned in Ruby Quest is quite possibly one of the most literal and unintentional examples around (think of it as having been a point-and-click adventure game, except by virtue of being roleplayed by post on an Imageboard, it was very open-ended). Ruby and Tom come across a medical cabinet with a small lock, which the players have Tom bash open with the crowbar. Some tranquilizer is found inside, which they take in a syringe. A little later, they encounter, have a fight with, and eventually subdue with the tranquilizer a psychotic and suicidal Stitches. Immediately after, it is discovered that Stichesactually had the key they were supposed to open the medical cabinet with. Then, instead of killing him and being done with it, the players stuff him into a revival locker and leave him, but not before also slipping him a portrait with himself, Ruby, Tom, and all the other patients and staff in the facility before things went to hell. Cut to the endgame of the story. Ruby, Tom, and an also unintentionally-rescued Jay, have unlocked the escape hatch to the facility, but Ace is in close pursuit. Tom realizes that Ace will catch them if all three of them try to go up the hatch, as they won't be able to close it in time. Someone has to stay behind and delay Ace. After much wailing and gnashing from the players and cry of foul play, it is somehow painfully decided that Tom be the one to stay behind. Ruby and Jay make their way up the ladder, just as Ace appears in the doorway. Tom prepares himself for the inevitable outcome, but then...guess who? Stitches suddenly tackles Ace out of nowhere, and gives Tom enough time to scramble up the ladder and slam the hatch (and also causing quite a few players to fervently thank the "Deus ex Machina"). By a combination of breaking something they weren't supposed to and being incredibly merciful, the players literally earned their happy ending.
Which apparently was a bad thing, because it meant someone's pick for "designated casualty" failed to die horribly.
Summed up spectacularly with The Nostalgia Chick's review of Don Bluth's Thumbelina, where the despairing heroine is surprised to find her prince Cornelius alive and well - "Things are impossible! Things are... oh! Hi dead boyfriend! Thanks for coming along and proving my pessimism wrong and not making me work for that happy ending!"
Counter Monkey: "The Last Ride of Tandem the Spoony." After making it through a horrendously difficult campaign against all odds, Tandem and the only other survivor find themselves with a ship that can cross dimensions, so they first go home to resurrect their friends, and then everyone was last seen sailing away to whatever adventures await them next.
Most of wildbow's Worm is very dark, and it's a very rough ride for the characters, especially the protagonist. But in the end, the world is saved and Taylor survives with a chance to start her life over.
Pact by same author is very rough to main characters too, and even darker than Worm, but its ending somehow even better: Blake turns into a sparrow and spents his time with Green Eyes and Evan; Rose presumably finds sanctuary from Lawyers in the Abyss and starts hurting them through writing and disseminating diabolic texts.
Bagger 288 just wants to find a place where he will be accepted. Unfortunately, Bagger 288 is a ridiculously massive mining machine appropriated dubbed by the internet as "Giant-Assed Saw Thing" that gets chased out of wherever he goes by either the military or protesters. When aliens show up though, he sprouts jet engines and takes the invader down with a Heroic Sacrifice, leaving him damaged to the brink of death and, when he sees all the people cheering for him, happy.
Year 3 (episodes 50-70) of Welcome to Night Vale. After a year of Cecil growing increasingly more depressed, unhappy, and discontent to the point of nearly leaving town, a misunderstanding that nearly cost him a close friendship, and desperately missing Carlos, everything is resolved in one night. Carlos returns to stay, Cecil and Dana's friendship is on the mend, Night Vale has a wonderful new opera house, and Hiram is finally jailed for his crimes (except for Violet.) The only person left unhappy is Kevin.