Such personal representative may at any time before or after the commencement of a suit for wrongful death settle with the defendant the amount to be paid to him as damages for the wrongful death of the decedent. If such personal representative was appointed in this state and settlement is made before the commencement of a suit such settlement must have the approval of the court of the representative's appointment. If settlement is made at any time after the commencement of suit, whether before or after judgment therein, such settlement must have the consent and approval of the court wherein the action is pending; provided, however, that if the personal representative was appointed in this state he may make such settlement upon the consent and approval of either the court wherein the action is pending or the court of his appointment. If all the statutory beneficiaries are of full age and competent and consent in writing to the proposed settlement the same may be made at any time, before or after suit, without the consent of either court.
SDCL 21-5-6