A carefully placed carabiner fixes that.

Just plug the extension cords together, hook both cords inside the carabiner, and pull.

The carabiner will only slide so far down the cords and keep them unplugging.

7 Carabiner Life Hacks| YouTube