(CNN) The man who took two hostages Monday at a UPS facility in Logan Township was shot and killed by police after the three emerged from the building, the office of New Jersey's attorney general said.

"There was apparently a relationship between the man and one of the women," Gloucester County prosecutor Charles Fiore said, adding that it was a "prior relationship."

Earlier, authorities said the man killed by police, identified as William Owens, 39, of Sicklerville, New Jersey, had been hospitalized. "According to the preliminary investigation, the shooting occurred after the gunman and hostages had exited the building," the attorney general's office said. The man was armed with a handgun.

Neither of the women held hostage was seriously harmed, Fiore said. Both were UPS employees.

The armed man did not surrender to police, he said, explaining, "There was an intervention." He did not elaborate.

Read More