By Alex Marshall

Just before 10 p.m. Tuesday, Celia Keenan-Bolger, who plays Scout Finch in “To Kill a Mockingbird” at the Shubert Theater, was giving her final speech of the night when a nearby motorcycle backfired several times.

But just days after mass shootings in El Paso and Dayton, Ohio, left 31 people dead, many people outside the theater feared another attack.

The Daniels Group, a construction firm, posted footage on Twitter of people fleeing Times Square.

Soon, frightened passers-by were screaming and banging on the doors of the theater, on West 44th Street, trying to get in, Ms. Keenan-Bolger wrote on Twitter.

“It was terrifying for us because we didn’t know what was happening or what to do,” she added.

Gideon Glick, who plays Dill Harris in the show, said on Twitter that the play had to be immediately stopped. “Screaming civilians tried to storm our theater for safety,” he wrote. “The audience started screaming and the cast fled the stage.”

“This is the world we live in,” he added. “This cannot be our world.”

Merle Dandridge, an actress who was in the audience, wrote on Twitter that she had crouched on the floor fearing for her life.

Other members of the audience fled through the emergency doors, including Peter Walsh. “I ran until no one was running,” he said on Twitter.

Ashlee Latimer, a Broadway producer, said that she was in the Glass House Tavern near Times Square when “a crowd of crying teens and families stampeded through the doors, many of them international tourists who couldn’t figure out what we thought was happening as we hid under tables and furiously texted people.”

“This is the American experience,” she said on Twitter, posting under the username Blessedterns.

The report was soon clarified by the police. “There is no #ActiveShooter in #TimesSquare,” the New York Police Department’s Midtown North Precinct said on Twitter“Motorcycles backfiring while passing through sounded like gun shots.”

“Please don’t panic,” it added.

This is not the first time a false alarm of gun violence has led to a stampede. In 2016, reports of shots fired at Kennedy International Airport led to a mass panic, with people cowering under cover and desperately calling relatives to find out what was happening.

A joint New York State and federal investigation into the events found that security protocols were seriously lacking and exacerbated the panic. It questioned what would have happened in a real emergency.

The experience on Tuesday may have been short-lived, but it brought home the reality of mass shootings for some.

“I’m still processing the whole experience,” Ms. Keenan-Bolger wrote. “But all I can think about are the young people who’ve had to go through the actual thing.”

“The trauma and fear that they have had to endure and what something like that does to a young person’s brain,” she added. “We cannot go on like this.”