Law enforcement officials advance on the building in Valparaiso, Ind., where a gunman held an unknown number of hostages Friday.

By M. Alex Johnson, msnbc.com

Updated at 10:50 p.m. ET: Police tactical officers stormed into an office building in Valparaiso, Ind., late Friday afternoon shortly after a gunman released the last of his several hostages. The man shot himself twice in the head and died later at a hospital, police said.

Two gunshots were heard, and tactical officers ran into the building through a shattered window. An ambulance then drove up to the building, and a cheer went up from the crowd gathered outside as someone — presumably the gunman — was brought out on a stetcher.

Valparaiso police said the gunman, later identified as Roy Ferguson, was taken from the scene with critical injuries. He died about two hours later, police said.

It was a quick resolution to a tense situation that had played out slowly for much of the day. The gunman had incrementally released his hostages over six hours before freeing his final two captives late in the afternoon.

Neither of the last two hostages was injured, authorities said. Earlier, a woman was freed and was treated at a hospital for a blunt force head wound, and a second woman was driven away in an ambulance after walking free. Valparaiso police Sgt. Mike Grennes said the woman with the head injury may have been struck by the gunman.

The man showed up about 11 a.m. ET at the offices of 21st Century Real Estate in the Prudential office building in Valparaiso, which is just south of Chicago. Fewer than 10 people were believed to have been inside when the gunman arrived.