When a mentally ill person is arrested or imprisoned on mesne process or execution in a civil action, a Justice of the Supreme Judicial Court or of the Superior Court or the judge of probate within his county, on application, may inquire into the case; issue a writ of habeas corpus; cause such person to be brought before him for examination; and after notice to the creditor or his attorney, if either is living in the State, and a hearing, if it is proved to the satisfaction of said justice or judge that the person is mentally ill, he may discharge him from arrest or imprisonment; and the creditor may make a new arrest on the same demand when the debtor becomes of sound mind. If he is arrested on the same demand a 2nd time before he becomes of sound mind and is again discharged for that reason, he is forever after exempt from arrest for the same cause.
14 M.R.S. § 5546