After the battle with Uchiha Madara, Hanyu could be certain of several things: first, the destruction of the Demonic Statue of the Outer Path; second, Uchiha Madara's death; third, the destruction of the Rinnegan.
And possibly Black Zetsu's death.
Black Zetsu was nominally Otsutsuki Kaguya's son, but in reality, he was a spiritual consciousness Kaguya had split off from herself. Hanyu did not know whether such a special entity could be destroyed through purely physical means... or whether sealing was the only way to deal with him.
But Black Zetsu had first suffered an invasion of his consciousness, then been continuously burned by Nametame. At the time, he had been crouching beneath the Demonic Statue of the Outer Path's feet, right at the very center of the explosion—the center of a thermonuclear blast. No matter what kind of entity he was, in theory, he could not have survived.
As for White Zetsu, honestly, they had not been Hanyu's target. Nor had they been hiding by Uchiha Madara's side... Put simply, Hanyu did not care about White Zetsu. White Zetsu alone posed too little of a threat.
However, these were all Hanyu's subjective judgments and might not necessarily align with reality.
The first issue was Izanagi. It was an ultimate Uchiha genjutsu that could only be activated while the Sharingan was active. Hanyu could only guarantee that Uchiha Madara had remained in the Rinnegan state throughout their battle. In theory, Madara had no opportunity to activate that technique during the fight.
As for Madara being farsighted enough to have prepared that genjutsu in advance... honestly, there was no answer to that. Uchiha Madara certainly had spare Sharingan that could be used to cast it.
And Hanyu could deal with Madara, but he could not deal with a bug.
If Madara could