MSNBC “Hardball” host Chris Matthews announced on air Monday that he was leaving the network, days after being accused of making inappropriate flirtatious comments to a guest and comparing Sen. Bernie Sanders’s victory in the Nevada caucuses to the World War II Nazi takeover of France.

A person familiar with Mr. Matthews’s decision said that his retirement was already “imminent,” but that the events of the past few weeks accelerated his exit from the network.

During a monologue at the beginning of “Hardball,” Mr. Matthews said he was leaving the show partly because he felt that there is a younger generation “ready to take the reins.”

He also made reference to allegations of inappropriate conduct. “A lot of it has to do with how we talk to each other: compliments on a woman’s appearance that some men, including me, might have once incorrectly thought were OK,” he said.

Mr. Matthews’s monologue was followed by a commercial break, after which Mr. Matthews didn’t reappear—with fellow MSNBC anchor Steve Kornacki taking over the show.