If your MOSFET is overheating, it could eventually break down and pass a voltage to the gate that may damage the digital ouput. Maybe a diode between the digital out line and the gate to block reverse voltage or a 5.1V zener on the digital out to conduct to ground. Have you verified that the specs of the MOSFET are sufficient for your application? Inadequate heatsinking? Personally, I would use an opto or galvanic isolation if the risk warrants it.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~