If the person injured appears before the court in which the action is pending at any time before trial, and acknowledges that he has received satisfaction for the injury, the court may, in its discretion, on payment of the costs incurred, order all proceedings to be stayed upon the prosecution, and the defendant to be discharged therefrom; but in such case the reasons for the order must be set forth therein, and entered on the minutes. The order is a bar to another prosecution for the same offense.
Ca. Pen. Code § 1378