A soldier who killed at least 21 people in a mass shooting that began on an army base and ended in a shopping mall standoff was killed by police Sunday morning.

Nearly 18 hours after the first shots were fired, 32-year-old Sgt. Jakrapanth Thomma was killed by security forces at about 9am, police announced this morning. He had been holed up inside the Terminal 21 Korat shopping mall since late Saturday afternoon and gunfire was heard sporadically through the night into dawn. One officer was killed during the final assault.

Before Jakraphanth was killed, nine hostages were rescued at about 6:30am. There was no immediate word on any other hostages he was reported to have taken.

Heavy gunfire can be heard in a video posted online and broadcast on television said to be the moment the gunman was killed. As people try to make sense of what unfolded on a Buddhist national holiday, tributes were pouring in for police Capt. Trakul Ta-arsa, who was killed by the gunman during the raid.

In an orgy of violence that seemed made for the social media spotlight, Jakrapanth shot dozens civilians and security forces in running battles with the authorities before escaping into the mall in what is Thailand’s third most populous city. His youngest victim was a 9-year-old boy. He had been live streaming and updating social media in real time with messages and videos of the attack before and after.

“No one can escape death” and “Should I give up?” were some of his messages posted online. While his motive was yet unclear, the man mentioned “revenge” on his Facebook account, which has been deactivated since 7pm.

Prior to Capt. Trakul’s death, 20 people had been killed by the gunman, Health Minister Anutin Charnvirakul said at 11:45pm. Sixteen died at the scene; four later at hospital. At least 31 were injured. The dead included at least two children: boys 9 and 13.

Update: Hostages at mall among 30 dead as Korat reels from trauma

Defense Ministry spokesman Kongcheep Tantrawanich confirmed that the man was a soldier stationed at the Surathampitak Military Base in Nakhon Ratchasima province. There were unconfirmed rumors online that he had been using the hostages as human shields.

Just before 8pm, he was said to have taken upward of 14 hostages. Police had advised those trapped inside the mall to call hotline 1195 and keep their phone volumes as low as possible to avoid detection by the shooter. Just before midnight, the Crime Suppression Division tweeted that special unit forces had secured the ground floor of the mall.

There were reports at about 10:20pm that most of those trapped inside the mall were rescued or able to escape. It was unclear whether they included any hostages.

Grove: Coconuts Brand Studio

Fast. Funny. Digital. We produce creativity that delights and influences customers. Join forces with us to slay buzzwords, rise above the noise, and sow the seeds of something great.