Whenever a complaint is filed for the foreclosure of a mortgage upon which there shall be due any interest or installment of the principal, and there are other installments not due, if the defendant pay into the court the principal and interest due, with costs, at any time before the final judgment, proceedings thereon shall be stayed, subject to be enforced upon a subsequent default in the payment of any installment of the principal or interest thereafter becoming due. In the final judgment, the court shall direct at what time and upon what default any subsequent execution shall issue.