If a person to whom a writ of habeas corpus is directed refuses to receive it, or neglects to execute it according to the provisions of this chapter and no sufficient excuse is shown therefor, the court or justice before whom the writ was returnable shall forthwith by process of attachment, as for a contempt, compel obedience to the writ, and punish the person guilty of the contempt.
Mass. Gen. Laws ch. 248, § 27