Toy Story 3 screenwriter Michael Arndt explains how the first draft of the Pixar movie had a more comedic ending. Between the toys nearly being incinerated, and Andy saying goodbye to his toys as he gives them to Bonnie and heads off to college, the third installment is remembered for having a dramatic and deeply emotional ending. The movie contains plenty of comedic moments, but its legacy is the impactful ending that almost becomes shockingly dark before concluding as a tearjerker. Although the franchise has since continued with two more sequels, including the upcoming Toy Story 5, it seems the series could have taken a different turn had it gone with an alternative ending.
https://screenrant.com/toy-story-3-alternate-ending-details-writer-response/