The Broadway musical “Natasha, Pierre and the Great Comet of 1812” will close Sept. 3, following a turbulent couple of weeks that saw the show engulfed in a controversy over a last-minute recasting of one of the title roles.

The production’s shaky financial straits came to light in the outcry that arose after Mandy Patinkin was cast for a three-week run in “Great Comet,” effectively cutting off the previously announced engagement of Okieriete Onaodowan in the role of Pierre. Producers had attempted to hustle Patinkin into the part in an effort to shore up the production’s sales following the July 2 exit of Josh Groban, whose 8½-month engagement had kept the show earning more than $1 million a week for the majority of its run.

Patinkin, a musical-theater legend who doesn’t show up on Broadway often these days, would have been a significantly bigger box office draw than Onaodowan, best known for his standout turn in a supporting role in “Hamilton.” But the move to cut short a run by a young African-American actor in favor of an older white performer raised a social-media firestorm over questions of diversity and representation.

Days after the controversy broke, Patinkin pulled out of “Great Comet” — leaving the show without a star to drive sales. As the musical’s creator, Dave Malloy, noted on Twitter, the production’s advance sales following the Aug. 13 exit of singer-songwriter Ingrid Michaelson looked grim, threatening a closure.

“Great Comet” was always something of a risky bet for Broadway, given its downtown aesthetic, quirky electropop score and an immersive staging that required a pricey reconfiguration of the Imperial Theater. But Groban’s long run in the show ensured the production never had an unprofitable week while he was in it, and it was hoped the attention he’d brought to the title could help the production establish a firmer foothold. Publicity during the run-up to the Tony Awards, along with a well-received production number on the Tony telecast, seem like they also might have helped bring in curious theatergoers. “Great Comet” led the Tony nominations list with 12 nods, and walked away with trophies for set and lighting design.

Some industry observers wonder how a show that’s never had an unprofitable week could prove to be in such a dire financial situation. The show’s producers, led by Howard and Janet Kagan, offered no comment on the closing.

Onaodowan’s run in “Great Comet” finishes Aug. 13, which would have been his final performance before Patinkin started his run. Scott Stangland will play Pierre Aug. 15-20, with Malloy, who originated the role of Pierre in the musical’s Off Broadway premiere, stepping into the part for the final run of performances Aug. 22-Sept. 3.