Days after a judge ruled against him in a child custody hearing, a father and his two young sons were killed on Sunday when police said he appeared to intentionally blow up a house with all three inside – a tragic ending to a bizarre case that began more than two years ago when his wife Susan went mysteriously missing in Utah.

A social worker brought the two boys to Josh Powell's home in Graham, Washington for what was to be a supervised visit, and Powell let his sons inside – but then blocked the social worker from entering, the Graham fire and rescue chief, Gary Franz, said.

The social worker called her supervisors to report that she could smell gas, and moments later the home exploded.

On Sunday, the lawyer for Susan Powell's parents, Chuck and Judy Cox, said the children had started talking to their grandparents about things they remembered from the night their mother vanished.

"They were beginning to verbalise more," said attorney Steve Downing, whose clients had custody of the children. "The oldest boy talked about that they went camping and that mommy was in the trunk. Mom and dad got out of the car and mom disappeared."

Ed Troyer, the county sheriff's spokesman, said emails that Powell sent authorities seemed to confirm that Powell planned the deadly blast. Troyer didn't elaborate on the contents of the emails, but said they make police believe "this is intentional, this is planned".

Authorities said they found three bodies in the home late on Sunday afternoon as fire crews and police continued to search the rubble. Troyer said it appeared some sort of accelerant was used to make the house burn faster.

Jeffrey Bassett, who represented Powell in the custody case, said he received a brief email from his client just minutes before Powell and the two boys died. It read: "I'm sorry, goodbye."

The email arrived at 12:05pm on Sunday, about 10 minutes before the explosion, but he didn't see it until two hours later, when others told him Josh and the boys had been killed.

He said he knew Josh was upset after being ordered to undergo a psycho-sexual evaluation recently, but he didn't see this coming.

Powell was under investigation in the disappearance of his 28-year-old wife Susan from their West Valley City, Utah, home in December 2009. He claimed he had taken the boys on a midnight excursion in freezing temperatures when she vanished.

The children, five-year-old Braden and seven-year-old Charles, had been living with Susan Powell's parents since Josh Powell's father, Steven, was arrested on child abuse image and voyeurism charges last autumn.

On Wednesday, a judge had denied an attempt by Josh Powell to regain custody, saying she wouldn't consider returning the two boys to their father until he underwent a psycho-sexual evaluation.

Sherry Hill, a spokeswoman for the state of Washington's Department of Social and Health Services, said the social worker who was with the children was not a Child Protective Services employee but a contract worker with a private agency that supervises visits for the state.

"The visit supervisor for this particular agency had taken the children to the home. When she does that, she sits through the visit and might take notes on her observations," Hill said. "She pulled up in the car, and the kids ran out ahead of her. He closed the door and locked it. She wasn't able to get in, and that's when she smelled gas."

Lawyer Steve Downing, who represented Susan Powell's parents, Chuck and Judy Cox, in the custody fight, said: "It's the most horrifying thing you can imagine happening … The Coxes are absolutely devastated. They were always very fearful of him doing something like this, and he did it."

Bassett said he represented Powell free of charge because "every parent deserves the right to an attorney". Powell called or emailed him at least once a day, and often more than that, and in their conversations "he never once admitted doing anything regarding Susan. In fact, he denied it".

Sgt Mike Powell of the West Valley City police department in Utah, which is handling the investigation into Susan Powell's disappearance, said it was too soon to say how Powell's death may impact their case.

"Quite frankly, this has obviously quickly unfolded up in Washington and we're obviously just working through the details ourselves here," said Powell, who is not related to the family.

The day of the hearing last Wednesday, Powell submitted a six-page affidavit attesting to his love of the boys and his competence as a caregiver and insisting that it was time for the boys to come home.

"For over four months already, my interactions with my sons and many other aspects of my character have been investigated and documented by CPS," he wrote. "I have proven myself as a fit and loving father who provides a stable home even in the face of great adversity. … It is time for my sons to come home."