
559 P.2d 222 (1977)
William E. VAUGHN, Petitioner,
v.
DISTRICT COURT IN AND FOR the SECOND JUDICIAL DISTRICT and the Honorable Gilbert Alexander, judge thereof, Respondents.
No. 27430.
Supreme Court of Colorado, En Banc.
January 17, 1977.
Rehearing Denied February 14, 1977.
Alfred C. Harrell, Denver, for petitioner.
R. Dale Tooley, Dist. Atty., Stephen S. Marsters, Deputy Dist. Atty., Denver, for respondents.
ERICKSON, Justice.
The petitioner was charged with possession of narcotics for sale and conspiracy. He was released on $15,000 bond. After the trial court granted the petitioner a continuance, the surety requested exoneration of his bond. As the sole basis for the request to withdraw, the surety stated:
"Well, it's almost getting ready to lead into a divorce action in my household, and I don't feel this is justified in causing the problems in my home."
The court granted the surety's request, over the petitioner's objection that (a) notice was not given to either defense counsel or the district attorney by the surety, and (b) the evidence was insufficient to allow withdrawal. Petitioner then sought relief in the nature of a writ of prohibition in this court, pursuant to Colo.Const. Art. VI, Sec. 3, and C.A.R. 21. We issued an order to show cause and now discharge the rule.
*223 The general function of a writ of prohibition is to enjoin an excessive or improper assumption of jurisdiction. It is designed to restrain rather than remedy an abuse of jurisdiction. See, e.g., Stiger v. District Court, 188 Colo. 407, 535 P.2d 508 (1975); City of Colorado Springs v. District Court, 184 Colo. 177, 519 P.2d 325 (1974). It is a discretionary writ. See Leonhart v. District Court, 138 Colo. 1, 329 P.2d 781 (1958). It does not correct mere error or provide a substitute for appeal. See, e.g., First National Bank v. District Court, 164 Colo. 9, 432 P.2d 1 (1967); Prinster v. District Court, 137 Colo. 393, 325 P.2d 938 (1958). Compare Weaver Construction Co. v. District Court, Colo., 545 P.2d 1042 (1976).
The petitioner's contentions are governed by section 16-4-108, C.R.S. 1973, which provides, in pertinent part:

"Exoneration from bond liability. (1) any person executing a bail bond as principal or as surety shall be exonerated as follows:
. . . . .
"(c) Upon surrender of the defendant into custody at any time before a judgment has been entered against the sureties for forfeiture of the bond, upon payment of all costs occasioned thereby. A surety may seize and surrender the defendant to the sheriff of the county wherein the bond is taken, and it is the duty of the sheriff, on such surrender and delivery to him of a certified copy of the bond by which the surety is bound, to take the person into custody and, by writing, acknowledge the surrender. If a compensated surety is exonerated by surrendering a defendant prior to the appearance date fixed in the bond, the court, after a hearing, may require the surety to refund part or all of the bond premium paid by the defendant if necessary to prevent unjust enrichment."
Accord, Crim.P. 46(a)(7)(I)(C).
In this case, the district court did not exceed its authority in overruling petitioner's objection that he was entitled to prior notice under section 16-4-107, C.R.S. 1973. That statute provides for notice where the amount or conditions of bail are to be altered. In the case of exoneration of a surety, the common law considers the principal to be within the custody of the surety. There is no prior notice requirement for exoneration of the surety when the principal is surrendered in open court. See, e.g., Taylor v. Taintor, 83 U.S. 366, 21 L.Ed. 287 (1872); Scott v. People, 64 Colo. 396, 172 P. 9 (1918); see generally D. Freed and P. Wald, Bail in the United States (1964); Note, Bail: An Ancient Practice Re-examined, 70 Yale L.J. 966 (1961). Section 16-4-108, C.R.S. 1973, codifies this authority. Accord, Fed.R.Crim.P. 46(g).
Assuming, arguendo, that petitioner was entitled under the statute to a hearing to determine whether the court should require the surety to refund part or all of the bond premium in order to prevent unjust enrichment, a writ of prohibition is not appropriate. Any civil claims petitioner may have for breach of contract or unjust enrichment have not been prejudiced by the ruling of the trial court. Moreover, the petition and record do not indicate that the petitioner requested, or that the court denied, the statutory hearing on a claim of unjust enrichment.
The petitioner seeks to have us read a requirement of actual or threatened breach of the conditions for bail into the statutory requirements of exoneration. Such an interpretation would be contrary to well-established law. The surety has the right to avail himself of the exoneration provisions of the statute for any reason sufficient to himself. See, e.g., United States v. Mack, 295 U.S. 480, 55 S.Ct. 813, 79 L.Ed. 1559 (1935) (Cardozo, J.); Taylor v. Taintor, supra; Reese v. United States, 76 U.S. 13, 19 L.Ed. 541 (1870); Note, 11 Harv. L.Rev. 541 (1898); Note, 26 Ill.L.Rev. 329 (1931). See also ABA Standards Relating to Pretrial Release § 5.4 and Comment at 68 (1968).
Accordingly, the rule to show cause is discharged.
PRINGLE, C. J., did not participate.
