You can prevent people from committing further violence by keeping them in a secure facility for the remainder of their days.
... but that's an entirely different debate from death penalty after facts have occurred.
HELSINKI (AP) — A man stabbed eight people Friday in Finland’s western city of Turku, killing two of them, before police shot him in the thigh and detained him, police said. Authorities were looking for more potential suspects in the attack.
~ https://www.seattletimes.com/nation-world/several-wounded-in...I've seen many examples of police engaging with firearms in the US that are eye watering .. eg: police firing across an intersection with moving traffic into a darkened mall | storefront that active shooters retreated into .. so, no clear line of sight, chance of hitting car that crosses fire line, chance of hitting innocents deeper in store, etc.
Or calling the cops on your family member because they are in psychosis or what have you, and they end up killing a member of your family. I do not think I would ever call the cops in the US to deal with such cases.