optimize device unplug