If a jury is discharged because the facts as charged do not constitute an offense punishable by law, the court shall order that the defendant, if in custody, be discharged therefrom, or, if admitted to bail, that the defendant's bail be exonerated, or if the defendant has deposited money instead of bail, that the money deposited be refunded to the defendant, unless in its opinion a new information or indictment can be framed upon which the defendant can be legally convicted, in which case it may direct the state's attorney to file a new information, or, if an information cannot be legally filed sooner, it may direct that the case be submitted to the same or another grand jury, and the provisions of rule 12 of the North Dakota Rules of Criminal Procedure, so far as applicable, as to the time and manner of the prosecution, govern the further proceedings under this section.
N.D.C.C. § 29-21-25