What happens at the end of Treasure Island and what could be an alternate ending?
At the end of the story, the captain and the other "good guys" leave all the mutineers who are still alive behind on the island. All, that is, except for Long John Silver, who comes with the good guys. They sail the Hispaniola to some unnamed city where Silver escapes. The other five return to England and share all the wealth that they got.
As far as alternate endings, it could really be anything that catches your fancy. The story actually has a happy ending, right? All the people that you like end up rich and happy and the bad guys get what they deserve. If you don't like an ending like that, make another one up.
You could say, for example, that the Royal Navy boards the Hispaniola and thinks that all of the men are pirates because they have pirate treasure. Or you could say that Silver (maybe with Gunn's help) kills the other four and takes all the treasure -- not just one bag. Or you could have one or more of the "good guys" turn bad and kill the others and take the treasure. There are all sorts of ways to end the story...
The Long John Silver character was such a great one that I hated to see him disappear entirely at the end. I would like to have seen Long John return in some manner--be it in America or back on English soil. A satisfactory scenario for me would be including a prologue, several decades in the future, where an elderly but still scoundrelous Long John reconciles with the adult Jim Hawkins. Perhaps Silver has another treasure map to share with Jim, and maybe Jim would be trusting enough to follow him on one more adventure.