(a) After the liability of the bail bondsman or surety has become fixed by forfeiture, and before payment, the bail bondsman or surety may be exonerated from the liability by the surrender ofwel the defendant and the payment of all costs; but may be exonerated from costs also if, in the opinion of the court, the bail bondsman or surety has been in