Massachusetts is a Castle Doctrine state

M.G.L. - Chapter 278, Section 8a

Chapter 278: Section 8A. Killing or injuring a person unlawfully in a dwelling; defense

Section 8A. In the prosecution of a person who is an occupant of a dwelling charged with killing or injuring one who was unlawfully in said dwelling, it shall be a defense that the occupant was in his dwelling at the time of the offense and that he acted in the reasonable belief that the person unlawfully in said dwelling was about to inflict great bodily injury or death upon said occupant or upon another person lawfully in said dwelling, and that said occupant used reasonable means to defend himself or such other person lawfully in said dwelling. There shall be no duty on said occupant to retreat from such person unlawfully in said dwelling.
Castle Doctrine in the US - Wikipedia, the free encyclopedia

The Castle Doctrine refers to a legal concept derived from English Common Law as it is presently applied in sections of the United States of America. It designates one's home as a place in which one enjoys protections from both prying and violent attack. In the United States, laws informally referred to as 'castle laws' can sometimes impose an obligation to retreat before using force to defend oneself. The Castle Doctrine provides for an exception to this duty. Provided one is attacked in their own home, vehicle, or place of business, in jurisdictions where 'castle laws' are in force, one may stand their ground against an assailant without fear of prosecution.

The opposite of a "castle" principle is the "Duty to Retreat", which is the case in most U.S. Northeastern states, such as Connecticut, New York, Pennsylvania, Massachusetts (where Castle Doctrine takes effect only within the confines of the 'dwelling'). Castle Doctrine laws in the U.S. are sometimes referred to as the "use of deadly force" [1] or "no retreat" laws, and originate in the home, but are sometimes (depending on the state) extended to the automobile or the business or any place where one has a legal right to be (a campground or park, for example).