Welcome .
It would really, really, really,really, really, really, really, really, really, really, really, help if we knew which engine you have rather than having to guess from the colour of the wires
So I will assume that this is a B & S ENGINE
I will assume it has the rectifier regulator mounted on the PLASTIC dip stick tube
So then I will jump to the conclusion that the ground strap that goes from the blower mounting bolt to the rectifier mounting bolt is not there or broken so the rectifier has no ground
And because I do not know what bloody mower the engine is on I will assume that the return power to he battery goes through the key switch so there is no circuit once the key is turned off
But of course this is all guess work because you could no be bothered to indicate which engine in what mower r even post in a specific engine or mower sub section.