N-MOSFET switching an H-bridge: problems with PWM
If I interpret your question correctly, this is probably what is happening:







simulate this circuit &ndash; Schematic created using CircuitLab

Most ICs have ESD protection circuit at the I/O pins which is represented by D1 and D2 above. When you want to disable the L293D by floating the "GND", "GND" gets pull toward Vcc by the loads. Current may flow through D2 as represented by the arrows.

Therefore, your MCU output is trying to power the circuit by pulling "GND" down through D2.

You are lucky that the H-bridge is powered by +5V. If it were +12V or something, it would probably burn out the MCU output.

Floating the "GND" of a circuit tends to have undesirable side effects. I avoid it because of the effort needed to take care of all the side effects and the risk of missing some.

Another side effect here is when the MOSFET is on, it still has significant resistance. That mean "GND" is not at 0V and would fluctuate depending on the load. So everything that are reference to "GND" are offset, that includes all the input pins.