Attempts to clean up errors when the device is unplugged.