A defendant convicted in the Halloween 2016 stabbing deaths of her parents — and who later killed the family pet to keep it from barking — was sentenced Tuesday to 40 years in prison.

Andrea Balcer, who turned 20 Monday, was 17 at the time of the slayings. She told authorities she “snapped” and killed her parents because of her struggle with gender identity. She was born Andrew T. Balcer but now identifies as a woman, CentralMaine.com reported.

At her sentencing hearing, Balcer asked her remaining family members to forgive her — but many of them called for Balcer to receive the maximum penalty.

“I do not speak today to beg for lenience or to try to save myself from due punishment. I’m here only to ask for one thing, the forgiveness of my family,” she said.

Balcer used a hunting knife to stab her mother nine times in the back about 1 a.m. Oct. 31, 2016, authorities said. She stabbed her father after he came to the bedroom to investigate his wife’s screams, CentralMaine.com reported.

He was later found dead on the kitchen floor after leaving a trail of blood from the bedroom, the report said.

Balcer later killed the family’s pet Chihuahua to stop it from barking, authorities said. An older brother managed to escape the house unharmed.

A defense attorney argued that at the time of the killings Balcer was grappling with a transition from male to female in isolation and without family support. She had no criminal record before the attacks in Winthrop, about 84 miles southwest of Bangor.

The older brother, Christopher Balcer, said the defendant’s excuses were “flimsy” and urged the judge to be firm.

“In my view, all leniency does is put a remorseless murderer back on the street,” he said.

Family and friends testified that the parents, Alice and Antonio Balcer, loving and supportive to both of their children.

Carl Pierce, Alice’s brother, said the suggestion that gender identity, abuse or lack of family support played a role was an “insult to our family, an insult to our society and an insult to the LGBTQ community.”

“There was no hatred. There was no malice. There was no ill will. There was resignation to be sure but ultimately there was acceptance,” he said.

Despite being a teenager at the time of the crimes, Balcer was treated as an adult in court proceedings, and she pleaded guilty under an agreement that capped her sentence at 55 years.

Justice Daniel Billings found mitigating factors including Balcer’s lack of criminal record, her good grades, her age and her acceptance of responsibility by pleading guilty.

But the judge declined to take into account her struggles with gender identity in imposing the sentence. The judge said other transgender people struggle with societal and family acceptance, and that it shouldn’t be used as an excuse for her actions.

The Associated Press contributed to this story.