Well the primary problem with killing the (sole) protagonist, is that there tends to be a lack of closure. Unless it’s very intentional and done right, it is rare that a protagonist’s death is going to be responded to positively if there are still plots that need to be tied up. If the series is ending and the villain is still alive, the hero’s friends are in danger, or there’s some sort of romance that wasn’t completely resolved, people will cry foul and likely write you off as an author, claiming your finale ruined the series.
Another thing to consider is how the death is handled. Did the cause of the character’s death happen because of an out of character action of either themselves or a friend? Did they fall for an obvious trap, or willingly let themselves die for no real reason? This has to be done right as well.
Also, are there multiple protagonists? If there are four characters whose stories we see simultaneously, it probably wouldn’t hurt too much to kill even as much as 3/4 of them off, so long as you follow the two above rules (rule 1 is less important in this scenario, as the story can continue and the plot threads can be seen to their conclusion.).
Tl;dr you need closure and a reasonable cause of death for the death to be ‘successful’.
Note that the above is a severe oversimplification. Protagonist deaths are often expected at the finale of a series, so it’s become a bit of a cliche (especially in dystopian fiction). Unless you’re doing something that is rare or never before seen, you are unlikely to evoke a preferred response in your audience.
Edit: My personal opinion is that if you don’t follow my two rules I don’t buy any more of your books. You can kill a protagonist (much as it pains me when done), but do it right. Looking at you, Divergent Series.