Outgoing Clarke County Attorney Michelle Rivera has been arrested for alcohol-related offenses twice in three months. (Image from video/KCCI)

The curtain was about to close on an ugly criminal case. It was Oct. 18 at the Clarke County Courthouse in Osceola, Iowa. An admitted sexual abuser was about to get his punishment.

Thirteen months earlier, in September 2017, Dennis Simmerman had been charged with sexually abusing a 13-year-old boy. In an interview with investigators, Simmerman, then 22, allegedly admitted "to engaging in a sex act with a minor,” court records indicated. He also reportedly said he exchanged obscene photographs with the teen. But Simmerman pleaded not guilty after he was initially charged, and the case inched slowly through the court system for nearly a year.

But by that Thursday afternoon in October, the defendant’s attorney had reached an agreement with Clarke County Attorney Michelle Rivera for his client to plead guilty to a class D felony, the Des Moines Register reported.

Simmerman, however, never got the opportunity to enter his new plea, and the judge never got to hand down a sentence. Moments before the hearing began, Rivera, the prosecuting attorney, was arrested on suspicion of public intoxication inside the courthouse.

Rivera, 42, was running for reelection at the time on the Democratic ticket, but the arrest did more than hurt her political chances. According to the Register, the state failed to file motions for extensions in Simmerman’s case on the day after the hearing.

On Monday, Judge Marti Mertz ruled that the charges against Simmerman had to be dropped and that the defendant was to be released after 15 months in custody. The judge’s order cited Rivera’s performance in the case, according to Des Moines’s KCCI. The state cannot refile the charges against Simmerman.

“The county attorney’s unavailability at the last hearing was the finale following unexplained periods of inactivity and lack of responsiveness,” the judge wrote.

Rivera lost her reelection campaign in November. But it remains to be seen whether the outgoing county attorney’s problems could affect the other criminal cases she handled in office.

“Everybody should be upset about it,” Mark Pennington, a former prosecutor from a nearby county, told the Associated Press. “That’s why you have to hold elected officials, including county attorneys, to a high standard.”

Rivera did not immediately return a request for comment.

Serving as county attorney since 2011, Rivera was generally liked around Clarke County, according to local sources.

“She went through school here. All the time we’ve known her, never did I hear a bad word about her,” one resident told KCCI.

“She’s tough, but just. She’s skilled, but humble. She is incredibly smart and good at her job,” attorney Adam Stone wrote in a letter to the Osceola Sentinel-Tribune in September urging voters to support her campaign. “She speaks softly, and carries a big stick. I know because I’ve been hit with that stick, in trial.”

Rivera apparently wielded that legal stick again after Simmerman’s arrest and confession to police. The Register reported that at one point early in the proceedings, the defendant’s attorney asked for a competency evaluation and argued that Simmerman suffered from a mental disorder. The judge, however, ruled he was competent for trial.

Later, Simmerman’s lawyer offered to have his client make an Alford plea, which means a defendant is maintaining his or her innocence but concedes that the prosecution has enough evidence to prove guilt beyond a reasonable doubt. Rivera reportedly turned down the idea. In August, Simmerman’s attorney broached the idea of his client pleading to a class D felony. A month later, Rivera accepted.

But according to the Register, on Oct. 18, before Simmerman’s plea hearing, a Clarke County sheriff’s deputy noticed Rivera in a courtroom. In a criminal complaint, the deputy would later write the attorney was “slurring her words and stumbling on her feet,” and noted that she “sat in a chair and swayed her head back and [forth], actions common with being intoxicated.”

The deputy asked to speak to Rivera in a small room by the courtroom. It was there that he detected the smell of alcohol on her. When she refused to take a breathalyzer test, the deputy arrested Rivera on suspicion of public intoxication.

After walking out of jail on a $300 bond, Rivera released a statement to the media.

“I genuinely apologize to my family, friends, law enforcement, colleagues, and my community for all that transpired last Thursday,” the county attorney wrote. “I can assure you all that I am taking every step necessary to get help, to fix this problem, and to make sure that nothing like this ever happens again.”

But the ramifications of Rivera’s arrest on the Simmerman case would prove critical. As the Register reported, the day after the plea hearing, prosecutors missed a deadline to file an important extension in the case. The defendant’s attorney then filed a motion to dismiss the case because his client had not been taken to trial within a year of his arraignment.

On Monday, the judge granted the motion. It is possible authorities could file different charges against Simmerman related to the alleged offense, although authorities have not indicated whether they plan to do so.

“If the defendant is not put on trial (and) is not tried within a year, you have the potential to have that case dismissed and that’s what happened here,” Marshall Orsini, Simmerman’s attorney, told KCCI. “I was obviously happy and relieved."

Rivera lost her November election, reportedly only pulling in 29 percent of the vote. She later pleaded guilty to the public intoxication charge and was fined $65.

Yet, despite her pledge not to let something like the October incident occur again, it did — last week.

The Register reported that a woman called law enforcement on Friday to complain about an erratic driver who had nearly hit her car, then blew through a stop sign and parked at the Clarke County Courthouse. From the license plate number reported by the witness, a Clarke County deputy learned it was Rivera’s vehicle.

When the deputy approached Rivera, he allegedly could smell alcohol on her breath. He asked her whether she had been drinking, and Rivera said she had consumed alcohol the night before but that it could still be in her system. She declined a breathalyzer test but failed a field sobriety test, police said.

Authorities learned that Rivera had taken her daughter to day care before going to the courthouse. She was arrested on suspicion of operating while under the influence and child endangerment. She is due back in court on Thursday.

More from Morning Mix:

A blind, worm-like amphibian that burrows underground has been named after Donald Trump

A humble weed grew in a cracked city sidewalk. Now it’s the Christmas Weed, a festive holiday destination.

What was Michelle Obama thinking after Trump’s inauguration? ‘Bye, Felicia.’