I had that happen to me once when I had the fan 'quick wired' to test things out, shut the key off & she kept right on running but not quite right
the fan motor
generator wasn't able to sustain voltage so the fan itself & the engine both slowly dropped rpm until coil volts dropped off to where it wouldn't run any more. pretty sure there was a good reason why I wanted to shut it off right away at that point too
the fan circuit needs to be isolated from the ignition switch. I have mine wired through a relay, the ignition switch only enables the relay trigger side Positive, and the fan temp sensor switches Ground/Earth