If the conditions of the bail bond have been performed and the defendant has been discharged from all obligations in the cause, the clerk of the court shall return to the defendant, unless the court orders otherwise, the entire sum which had been deposited.