handle the unplug of a device