I'm using an N-channel MOSFET (IRL40B209) to turn my 3D printer on and off with a Raspberry Pi running Octoprint. The printer runs on 24V at up to 15A and the MOSFET switches the low side of the input to the printer mainboard (SKR Mini E3 V1.2 --
schematic. I'm connecting to RX2 and TX2.). The MOSFET gate is controlled by a GPIO pin that goes through a 3.3V to 5V logic shifter:

(BJT is a 2N3904).
This was all working fine, but when I connected the UART pins from the Pi to the printer board, the Pi got quite hot and died (red light but no green activity light, and nothing on HDMI). It's worth noting that Octoprint initialises the GPIO on startup so the UART pins were probably actively pulled low by the Pi.
My guess for the reason is that there are rail protection diodes inside the Pi's GPIO block and somehow the UART pins on the printer mainboard were connected to 24V when the board was off. The mainboard UART input goes straight into an STM32F103 on the mainboard (no external pull-ups). 3.3V is provided by an AS1117 powered from an AOZ1282 buck converter, which has a P-channel MOSFET inside it. Maybe the STM32F103 was sourcing 24V from its GPIO protection diodes and the Pi was getting it?
TLDR:
My Pi is dead. I have ordered two more. Is it worth persisting with this (e.g. putting 10k resistors on the UART lines to try and limit current, or any other suggestions you have) or is it just a bad idea all round to connect push pull GPIO to something powered from 24V while it's switched off low side?