(a) A certified copy of the bail bond must be delivered to the sheriff, who must detain the defendant in his custody thereon, as upon a commitment. The sheriff must acknowledge the surrender by a certificate in writing, and must forthwith notify the court in which the case is pending that such surrender has been made.
(b) Upon the bail bond and the certificate of the sheriff, or upon the surrender to the court in which the case is pending, such court must, upon five days notice to the district attorney, order that the bail be exonerated. On filing such order, the bail is exonerated accordingly. 2. For the purpose of surrendering the defendant, an obligor or the person who posted cash bail for the defendant may take him into custody at any place within the state, or he may, by a written authority indorsed on a certified copy of the bail bond, empower any person over twenty years of age to do so. 3. At any time before the forfeiture of cash bail, the defendant may surrender himself or the person who posted bail for the defendant may surrender the defendant in the manner prescribed in subdivision one. In such case, the court must order a return of the money to the person who posted it, upon producing the certificate of the sheriff showing the surrender, and upon a notice of five days to the district attorney.