The person so depositing a sum of money in lieu of a bond, recognizance or undertaking shall be entitled upon application to the court wherein such deposit has been made and subject to the order on which such funds are held to receive back such sum whenever the purposes for which it has been received and deposited have been accomplished and the person is entitled to repayment thereof.