Joan Allen, Dustin Hoffman, John Ortiz and Dennis Farina (left to right) in a scene from “Luck.” (Gusmano Cesaretti / AP)

The final two episodes of the series, which was by David Milch and Michael Mann and stars Dustin Hoffman and Nick Nolte, will be shown, the network said.

“While we maintained the highest safety standards possible, accidents unfortunately happen and it is impossible to guarantee they won’t in the future,” HBO said in a statement.. “Accordingly, we have reached this difficult decision.”

Gary Stevens, a former jockey who also stars on the series, tweeted: “So bummed. Peace out to all my family in #luck.”

The series showed another side of horse racing, a less romantic side than “Seabiscuit” or “Secretariat.” This was “not your typical Hollywood depiction,” The Post’s Andy Beyer wrote. Two horses were euthanized after they were injured during the filming of racing scenes for the first season of the show. The American Humane Association, which oversees animal welfare and safety on Hollywood sets, had called for production to be halted at Santa Anita after the second horse’s death. New protocols were put in place and racing scenes resumed.

On Tuesday, a horse was euthanized after it reared and fell back, suffering a head injury, as it was led to a stable by a groom. The AHA demanded that “all production involving horses shut down” pending investigation and HBO agreed.

“PETA will be calling on them,” the organization said in a statement, “as we have done from the start, to use stock racing footage instead of endangering horses for entertainment purposes.”