I believe there are two mechanisms:
1) as @gondwanalon wrote, there is a logical/digital interlock that won’t allow the car to move if the charger is connected. (That is, the starter interlock is set).
2) As I understand it, the charger ‘nozzle’ itself has some sort of plastic lock that, when stretched enough, will break apart (i.e. separate) to cut the electrical connection to the vehicle. You might have to buy a new plastic piece, but your walls won’t fall down.
This is analogous to the ‘regular’ gas pumps where there are breakaway valves built into to gas pumps that separate.
See this