Avoid locking a NULL context when a device is disconnected