SHEFFIELD, Iowa (AP) — Two Iowa deputies were cleared Monday in the fatal shooting of a man after an investigation found he pointed a pellet gun at the deputies and thanked them after he was shot.

The Iowa Attorney General’s Office found that Franklin County deputies Chase Weinandy and Ben Baskerville were justified in the shooting of Matthew T.J. Davis, 30, on June 20. The office based its review on an investigation by the Iowa Division of Criminal Investigation, which had access to body cam footage.

The deputies were called by a woman who said her former partner was at her home in the small northern Iowa community of Sheffield and was drunk, armed with a gun and suicidal. The caller told a 911 dispatcher that Davis said he wanted to be shot by police.

When deputies arrived, they found Davis in a driveway and armed with a gun. They told him at least 17 times to drop the gun. But after he approached them and raised his weapon, Baskerville fired two times with a rifle.

While waiting for an ambulance to arrive, Davis told the deputies, “Thank you for shooting me,” according to the report.

An autopsy determined Davis died of a gunshot wound to the abdomen.

The investigation found Davis was armed with a pellet gun but noted the deputies had been told he was carrying a gun and had no way of knowing what kind of weapon he had.