Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Jim Gard has been a math teacher for 36 years. One of the basics of the job is that "you're responsible for the kids every day," he said Wednesday. But "certainly, today was different."

Gard's math class at Marjory Stoneman Douglas High School in Parkland, Florida, was just finishing up a review for a test Wednesday when "the fire alarm went off, which I thought was unusual because we'd just had a fire drill."

It wasn't another fire drill, or even a fire. It was far, far worse. Authorities said Nikolas Cruz, a 19-year-old man who'd recently been expelled from the school, had returned to campus and opened fire with an AR-15 semi-automatic rifle. Seventeen people were killed and more than a dozen wounded, five with life-threatening injuries.

Because they'd just had a fire drill, Gard told his students to wait a minute before leaving, but then "our administrator got on and said, 'Evacuate the building,'" he told MSNBC on Wednesday night.

A superseding announcement quickly came, he said: "code red." All but six of his students fled, Gard said; following protocol, he and the rest returned to the building, hid in a closet and "just turned the lights off, as you're supposed to do in a code red — you know, an active shooter."

Gard said that all of his students had been accounted for and that "thank goodness, they're safe."

Related: Social media videos showed terror from Florida shooting

It was Cruz who set off the fire alarm, according to Sen. Bill Nelson, D-Fla., "so the kids would come out into the hallways."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Melissa Falkowski, an English and journalism teacher, told a similar story — she and her class evacuated because of the fire alarm but returned to the classroom when the code red was declared. They, too, hid in a closet until a SWAT team showed up.

"The kids, some of them, were hysterical from moment one," Falkowski said in an interview with NBC's "Today" on Thursday morning.

Because her classroom is on the other end of the campus and had been cleared, more students and teachers were taken there — about 150 in all, Falkowski earlier told MSNBC — before they were moved off campus.

Falkowski said she and her colleagues were frantically texting one another for more information. That's when she learned that one of her colleagues was among the injured. She also got a phone call from her mom.

"In that moment, I sort of lost my composure. I told her I was OK but I had to get off the phone," she said. "The kids needed me to be composed."

Photos: Florida school shooting leaves families distraught

Falkowski said she didn't know Cruz but had heard students talking about him.

Julien Decoste, a senior, said he knew "something was up" when the fire alarm went off a second time and he saw other students running. Recovering from major knee surgery two weeks ago and walking on crutches, Decoste couldn't run and didn't know what to do — until he saw a physical education teacher who told him to hurry into her classroom.

"I'm hopping to her for dear life, just trying my hardest to get there, and then right when I get to the door I hear gunshots to my left," said Decoste, 18.

"They put us in a closet, they took all of our names," he said. "There was 15 of us in one closet, crammed in there."

The Broward County schools superintendent, Robert Runcie, said Wednesday that Cruz had recently been expelled from Douglas for disciplinary reasons and was currently enrolled in another school in the district. Broward County Sheriff Scott Israel said investigators were reviewing social media postings that he described as "very disturbing."

Falkowski said that in the past, when school officials have been made aware of threats on social media, "they take precautions, and they investigate and take the precautions at school to make sure nothing happens."

Many students, like Eddie Bonilla, a senior, described Cruz with words like "a little bit off" and "troubled." Cruz used to show off his guns, brag about shooting them "for fun" and "threatened to bring the guns to school multiple times," Bonilla said.

Other students, he said, "threw jokes around that he'd be the one to shoot up the school."

Decoste said Cruz was "not the best kid," someone who "did a lot of bad things at school" and sometimes posted pictures of "dead lizards and stuff that he shot" on his Instagram feed.

But Gard, the math teacher, said Cruz left little impression when he was a student in one of his classes last year.

"I never had any problems with him," Gard said Wednesday night. "He wasn't a problem in class — but that was over a year ago."