In such case, if the party injured appear in the court in which the cause is pending at any time before the final judgment therein, and acknowledge, in writing, that he or she has received satisfaction for the injury, the court may, in its discretion, on payment of the costs incurred, order all proceedings to be discontinued and the defendant to be discharged. The reasons for making the order must be set forth therein and entered in the minutes. Such order is a bar to another prosecution for the same offense.