As far as I know, a disabled cargo hatch is the best defense against just that. If the hatch is unpowered, you can't accidentally hit the "Eject all cargo" button which is like next to the "Release landing gear" and "Open cargo scoop". So smart, like placing a self destruct button next to the FSD button. Useful, because you use both quite often...
Plus it protects you against cargo stealing drones. If there is no power, they will not be able to reprogram it to open. I wish for a limpet v2 that comes with a small power pack to automatically open unpowered (therefore not locked) hatches.