Creativity tends to be a pretty big part of being a scriptwriter. Yet being creative has definitely gotten harder as the years have gone on - granted, the human imagination is limitless, but when over a century of movie-making has established tropes that work and those that don't, it can be very easy to go into autopilot and ride the rails of these already-established plotlines.
Case in point, the suddenly negative ending. You can see why scriptwriters choose to go with it - it's probably cathartic to escape the formula of happily-ever-after, and if executed well you can knock an audience silly with the unexpected. And to be fair, they often do theres plenty of endings you didnt see coming that knock the wind out of you.
Yet occasionally, these endings can be added just to create artificial shock, disappointing the audience by pretty much invalidating everything thats come before. These movies can anger audiences and live in infamy among critic circles, because there's nothing like the gut-punch that comes out of nowhere.