Figure out how to make the NPC less distracting
The other two answers are great, but as described it sounds like a social problem bleeding into the game.
Your player is frustrated and no one else seems to notice or care.
The game gives them agency that they don't have socially, so they
used what they had to remove their frustration.
Without knowing more about the details of the game session, the best solution is probably to ask the frustrated player, then the whole table, how to resolve the issue.
In-game, I think you handled it right. The other players should have a choice in at least attempting to stop NPC murder. But it sounds like there is a root cause that needs investigation.
As general advice for not making your NPCs targets for murder:
- NPCs need to be useful. An NPC who isn't pulling their weight is luggage, not a person.
- NPCs can't be too useful. Assistance doesn't mean doing things for the players. Especially in combat. Combat NPCs should fill a missing role, and never outshine a player in their established role.
- The players are the decision makers. Hopefully your rescued prince, despite being royalty, knows when to shut up and let the professional adventurers decide how to escape the bad situation.
- Murder has consequences. There should be in-game motivations for characters to not murder someone, even if they want that someone to die.
- NPCs shouldn't be complicated. Player Characters have a lot of stats and features. It's already a full time job managing the world and monsters, don't slow things down with a character complex enough to be someone's full time job.
I've recently come across issues with my players finding NPCs bothersome.
Regarding reason #1, in The Sunless Citadel, the first adventure in Tales from the Yawning Portal, there party has a chance to rescue a gnome captured by goblins, who can choose to accompany the players.
This gnome isn't a full player character, and isn't very tough, so I'd play him as keeping back and only taking a stab at enemies with a borrowed dagger when absolutely necessary. He can heal (like a L2 Cleric), but with limited spell slots he often came off as useless. He didn't really earn his keep until he saved a downed player character by dragging them out of combat before casting a healing spell, and even then the players (well, one specifically) only begrudgingly accepted his presence.
For my final point, in our most recent dungeon I introduced basically a GMPC that I intended mostly to be that other adventurer that happens to be adventuring in the same place at the same time as the party, that they could bump into here and there but would stay out of each other's way. When half of the group couldn't make it to a recent session, I brought this NPC as an ally to round out the group and give them confidence.
I unfortunately made them rather complicated, and had to take extra table time during combat to check class features and look up a couple of spells. Though the players were grateful for the help in combat, I could see in their expressions that they would have preferred things to be moving faster. I haven't yet solved this for myself, but being aware of the problem will make it easier to avoid this issue in the future.
Please see other questions about GMPCs as explanation for item #2, railroading for item #3, and the other great answers for #4.