It can absolutely work, if you're going for a particular effect.
If you need to shift perspective to somebody else, it's a nice dramatic way of doing that. If you need to end the story on a morbid note, it's a pretty common method of doing that. If you want a sad ending, sometimes this is the way to do that, too.
It's not really as controversial as some might think, because it's been done plenty of times. It's not even that unusual to do it before the end.
Just look at Pulp Fiction. It has multiple protagonists that it follows the point-of-view of, and one of them, Vincent, straight up dies after not listening to his partner's advice. It serves the story, because the encounter motivates another protagonist to mobilise. It also provides a moral about recklessness which is a running theme in the film.
Hell, there are films where we open with a flash-forward of the protagonist about to die. There are stories where there are multiple protagonists who are in conflict with each other and one dies in the process. (I'm The King Of The Castle, for example... or even visual novels like Detroit: Become Human where Markus and Connor are on opposing sides and if you go for a violent conflict one will die)
Killing a protagonist is a really useful tool. It can work, it does work and nobody's ever considered it to be outlandish.