Upon application for such a stay of proceedings, the court shall hear the parties, and if upon the hearing it appears that the premises of which possession is sought to be recovered are used for dwelling purposes; that the applicant cannot secure suitable premises for himself and his family elsewhere within the city or town in a neighborhood similar to that in which the premises occupied by him are situated; that he has used due and reasonable effort to secure such other premises; that his application is made in good faith and that he will abide by and comply with such terms and provisions as the court may prescribe; or that by reason of other facts such action will be warranted, the court may grant a stay as provided in the preceding section, on condition that the terms upon which such stay is granted be complied with.
In any action to recover possession of premises occupied for dwelling purposes brought pursuant to this chapter in which a stay or stays of execution have been granted, by the court or by agreement of the parties, or in any such action where there is an agreement for judgment that grants the tenant a right to reinstate the tenancy, no execution shall issue prior to the expiration of the period of such stay or stays or such reinstatement period unless the plaintiff shall first bring a motion for the issuance of the execution and the court after a hearing shall determine that the tenant or occupant is in substantial violation of a material term or condition of the stay or a material term of the agreement for judgment.
Mass. Gen. Laws ch. 239, § 10