Example of Criminal Procedure Act in South Africa
In South Africa, §49 Criminal Procedure Act used to provide:

(2) Where the person concerned is to be arrested for an offense referred to in Schedule 1 or is to be arrested on the ground of having committed such an offense, and the person authorized under this Act to arrest or to assist in arresting him cannot arrest him or prevent him from fleeing by other means than killing him, the killing shall be deemed to be justifiable homicide.
In some jurisdictions, the castle doctrine allows the use of deadly force in self-defense against an intruder in ones home. Other jurisdictions have stand-your-ground laws that allow use of deadly force in self-defense in a vehicle or in public, without a duty to retreat. Where the persons death is inflicted by the effecting of lawful arrest or prevention of lawfully detained persons escape, quelling riot or insurrection when the use of force is "no more than absolutely necessary". The doctrine of necessity allows, for example, a surgeon to separate conjoined twins, killing the weaker twin to allow the stronger twin to survive. (This is not recognized, for example, in England and Wales). In the United States, the 2005 Unborn Victims of Violence Act changed the legal definition of human fetuses to "unborn children", formally defining feticide as murder (under USC §1111). However, the law retains explicit exceptions which prohibit the prosecution "of any person for conduct relating to an abortion," "of any person for any medical treatment," or "of any woman with respect to her unborn child," thereby preserving the right to an abortion stemming from Roe v. Wade. However, Roe v. Wade was overturned in 2022 by Dobbs v. Jackson Womens Health Organization. Several countries, such as the Netherlands, Belgium, Switzerland, Japan, Canada, and the U.S. states of Oregon and Washington allow both active and passive euthanasia by law, if justified. The "heat of the moment" defense for crimes of passion: death results from a situation where the defendant is deemed to have lost control.