Upon the hearing of such action as provided in subsection 1, the court may order the repayment of prior installments or deposits or any part, as a condition of terminating the contract and resuming possession of the property, or may, in its discretion, on its own motion, and shall, on application to it by such person in military service or some person on the person's behalf, order a stay of procee