There's communication between the device and the power brick. When the communication stops the power stops being delivered. Not sure how Apple is doing that these days with the MagSafe USB-C they have introduced on their laptops since you can plug the other end into any and all USB-C capable chargers.