Add code to deal with unplug events