CNN  — 

Democratic presidential candidate Joe Biden reflected on how personal tragedy has affected his faith while connecting Wednesday night with a pastor who lost his wife in the 2015 mass shooting at a church in Charleston, South Carolina.

The Rev. Anthony Thompson’s wife, Myra, was one of nine African Americans killed by a white supremacist at a Bible study at the Emanuel African Methodist Episcopal Church. Thompson asked Biden at a CNN town hall in Charleston about the former vice president’s faith and how it would inform his decision-making if he’s elected president.

“Well, Reverend, I kind of know what it’s like to lose family, and my heart goes out to you,” Biden said.

“I don’t know how you’ve dealt with it, Reverend,” Biden said. “But the way I’ve been able to deal with when my wife was killed and my daughter was killed and then my son died, I’ve only been able to deal with it by realizing they’re part of my being. My son Beau was my soul.”

Biden’s first wife and infant daughter were killed in 1972 in a car crash, right after he had won his US Senate seat. Biden’s son Beau, an Iraq War veteran who served as the attorney general of Delaware, died in 2015 from brain cancer at the age of 46.

The Charleston shooting occurred only weeks after his son’s death, and Biden visited the church with then-President Barack Obama and first lady Michelle Obama. Biden said at Wednesday’s town hall that he then had gone back to the church in 2015 to attend a Sunday service, “because I had just lost my son, and I wanted some hope.”

“Because what you all did was astounding,” Biden said, after choking up at the mention of his son. He said those in the community affected by the massacre forgave the shooter. “The ultimate act of Christian charity,” he said.

Biden said, “I’m not trying to proselytize, I’m not trying to convince you to be, to share my religious views. But for me it’s important because it gives me some reason to have hope and purpose.” 

He spoke about how his son had urged him right before he died to stay engaged and not retreat into himself. Biden said that every day he wakes up and “I ask myself, I hope he’s proud of me today.”

“It took a long time to get to the point to realize that that purpose is the thing that would save me,” he said. “And it has.”

“To forgive is divine. What you did, you changed, you brought down that Confederate flag,” Biden said to Thompson. “You’re the ones who changed the attitude in this state in a way that was profound. And I think that’s how it gets done.”

CNN’s Dan Merica contribute to this report.