The charging cable (on US implementation), should lock the plug into the car when the car is locked until you either unlock the car, or it achieves 100% charge. Now, if the CCS unit turns off, it might unlock, I've not tried that. This assumes that you actually got the plug on fully, but if you didn't, the latch should not return to complete the interlock, and it wouldn't actually start charging. The original implementation of the firmware did not unlock the plug once the car was charged...you had to unlock the car for that to happen...somewhere after a bit of a year or so, they updated the software to enable that function. It's possible that the latch on the plug is damaged, and the latch pin in the car won't hold it in place. Or, the latch in the car is broken or stuck.
2014 i3 BEV, 2021 X5 45e
(The i3 will be sold soon, <17K-miles, interested?)