(Reuters) - A 39-year-old gunman opened fire at a United Parcel Service Inc facility in New Jersey and held two employees hostage for hours on Monday before police fatally shot him, officials said.

William Owens barricaded himself and two women inside the sorting facility in Logan Township and police sent a heavily armed SWAT team to the location, about 25 miles (40 km) southwest of downtown Philadelphia, the New Jersey Attorney General’s Office said in a statement.

The standoff ended when Owens was shot while exiting the building with the hostages, the statement said.

Owens, who was from the nearby town of Sicklerville, was taken to a hospital where he was pronounced dead.

Neither of the two women the gunman took hostage was seriously injured, authorities said, and there were no reports of other casualties.

The gunman apparently had known at least one of the women, Gloucester County Prosecutor Charles Fiore told reporters.

UPS praised the police for their handling of the situation and said all of its employees were safe.

“The incident is concluded and all of the employees are accounted for and being attended to by local officials,” the company said in a statement.

The New Jersey Attorney General’s Office said it would investigate the police shooting of Owens.