Return of the King (and the non-return of my faulty memory)

Spoilers if you are one of the 3 people who don’t know how it ends…

So, I was ROTK the other day (and am planning on returning tonight in a repeat of last year’s Sushi + Lord of the Rings New Year’s Eve Celebration) and I was surprised at how different my memory of the ending from the book (last read in 1991 or something) was from the actual ending of the movie (which, I later checked, is taken right out of the book). I had remembered that Smeagol took the ring from Frodo and sacrified himself to destroy it and, at the last, Frodo had a vision of the young boy Smeagol was before he was corrupted. I was surprised that the ending was Frodo succumbing to the ring and its end being a struggle between the two and an accidental death and destruction. So, either my brain wrote a new ending (which, I have to admin, I like better) in the last 12 or so years or I am confusing this ending with the end of another book. Anyone have any ideas out there?

Happy New Years!