Where an application for a writ of habeas corpus has been made by or on behalf of any person other than a defendant in a criminal case, an appeal may be taken to the court of appeal from a final order of a superior court granting all or any part of the relief sought; and where such application has been heard and determined in a court of appeal, either on an application filed in that court or on appeal from a superior court, and all or any part of the relief sought has been granted, an application may be made for a hearing in the Supreme Court. Such appeal shall be taken and such application for hearing in the Supreme Court shall be made in accordance with rules to be laid
down by the Judicial Council. The court which made the order granting relief or the court in which the appeal or petition for hearing is pending may, in its discretion, and upon such conditions as it deems just stay the execution of the order pending final determination of the matter.