Penal Code § 1384
CHAPTER 8. Dismissal of the Action for Want of Prosecution or Otherwise
If the judge or magistrate directs the action to be dismissed, the defendant must, if in custody, be discharged therefrom; or if admitted to bail, his bail is exonerated, or money deposited instead of bail must be refunded to him or to the person or persons found by the court to have deposited said money on behalf of said defendant.