Any person who has lawfully entered a house for the purpose of making an arrest, or who while therein makes an arrest, may break open the door or window thereof, if detained therein, when necessary to exit the house, and an officer may do the same when necessary for the purpose of liberating a person who, acting in the officer's aid, lawfully enters for the purpose of making an arrest and is detained therein.
N.D.C.C. § 29-06-26