MOSFET gate spikes when load is disconnected
As the fans are "disconnected", that is , wires physically removed, sparks are generated.

Those sparks arcs will explore all possible paths for the charge to return home. 

Grounds are upset

VDD is upset

And the FET drain-gate capacitance conducts that spike into the MCU output.

Thus you have an ESD event, yet you expect continuous operation.

Review your gnd_ing.

And place a resistor between FET gate and the MCU.