Add 2 new blocks, it allowed to attach the trains between them. And a new block to auto detach them.
Basic couplers:
Attach when the tow train chock each other; And can be detach by the player whit a wrench.
Auto couplers:
Like the basic, but the player can detach the couplers from the locomotive whit a new key bind.
De-coupler block:
Place like a signale on the rail, activate by redstone. Decouple all Auto couplers passing over it.
This would make it possible to make marshalling yards!