A Colorado resident was following the law when they shot and killed a mother bear accompanied by her three cubs early Thursday out of fear the sow was trying to enter their home, officials said.

The orphaned cubs had scattered by the time wildlife officials discovered the mother bear’s body Friday morning, Colorado Parks and Wildlife (CPW) said in a news release Sunday. Two of the cubs were later found taking refuge up a tree and were safely captured. The third cub was not located.

BLACK BEAR FINDS ITS WAY INSIDE MONTANA HOME: 'HE WAS TIRED AND CLIMBED UP INTO THE CLOSET FOR A NAP'

“This is an unfortunate occurrence, and you never want to hear of a sow getting killed and cubs being orphaned,” CPW Northeast Region Manager Mark Leslie said.

Under Colorado law, it is legal to use lethal force to protect one’s personal safety when feeling threatened by a bear. Any such killing must be reported within five days, the state wildlife agency says.

OREGON BEAR PUT DOWN AFTER PEOPLE FEED HIM, TAKE SELFIES, OFFICIALS SAY

CPW officials said the case underscores the challenges of managing wildlife in the area. Colorado’s Front Range already provides bears with ample habitat and food sources. Attractants such as garbage, pet food and the smells from barbeque grills can lure the animals to nearby neighborhoods.

“If you are putting your trash out the night before collection, or if you have a bird feeder out this time of year, you are harming the well-being of our bears,” Leslie said. “That leads to human-bear conflicts that can escalate into dangerous and sad situations like we are seeing here in Castle Pines.”

CLICK HERE TO GET THE FOX NEWS APP

CPW officials took the two orphaned cubs to Frisco Creek, a wildlife rehabilitation center operated by the state, to help them through their first hibernation without their mother. They will be released back into the wild when they can survive on their own, the CPW said.