Index: uspace/drv/vhc/conn.h
===================================================================
--- uspace/drv/vhc/conn.h	(revision afc4fbbdd71b68ed8e64f7044745616c69c4628d)
+++ uspace/drv/vhc/conn.h	(revision 6967c1430d08605b85c7be0744903e84cae79ec5)
@@ -51,4 +51,5 @@
 
 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
+void on_client_close(device_t *);
 
 
Index: uspace/drv/vhc/conndev.c
===================================================================
--- uspace/drv/vhc/conndev.c	(revision afc4fbbdd71b68ed8e64f7044745616c69c4628d)
+++ uspace/drv/vhc/conndev.c	(revision 6967c1430d08605b85c7be0744903e84cae79ec5)
@@ -88,5 +88,5 @@
 		int callback = IPC_GET_ARG5(*icall);
 		virtdev_connection_t *dev
-		    = virtdev_add_device(callback);
+		    = virtdev_add_device(callback, (sysarg_t)fibril_get_id());
 		if (!dev) {
 			ipc_answer_0(icallid, EEXISTS);
@@ -99,8 +99,6 @@
 		int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH);
 
-		dprintf(0, "virtual device connected (name: %s)",
-		    rc == EOK ? devname : "<unknown>");
-
-		/* FIXME: destroy the device when the client disconnects. */
+		dprintf(0, "virtual device connected (name: %s, id: %x)",
+		    rc == EOK ? devname : "<unknown>", dev->id);
 
 		return;
@@ -110,4 +108,22 @@
 }
 
+/** Callback for DDF when client disconnects.
+ *
+ * @param d Device the client was connected to.
+ */
+void on_client_close(device_t *d)
+{
+	/*
+	 * Maybe a virtual device is being unplugged.
+	 */
+	virtdev_connection_t *dev = virtdev_find((sysarg_t)fibril_get_id());
+	if (dev == NULL) {
+		return;
+	}
+
+	dprintf(0, "virtual device disconnected (id: %x)", dev->id);
+	virtdev_destroy_device(dev);
+}
+
 
 /**
Index: uspace/drv/vhc/devices.c
===================================================================
--- uspace/drv/vhc/devices.c	(revision afc4fbbdd71b68ed8e64f7044745616c69c4628d)
+++ uspace/drv/vhc/devices.c	(revision 6967c1430d08605b85c7be0744903e84cae79ec5)
@@ -59,8 +59,9 @@
  *
  * @param phone Callback phone.
+ * @param id Device id.
  * @return New device.
  * @retval NULL Out of memory.
  */
-virtdev_connection_t *virtdev_add_device(int phone)
+virtdev_connection_t *virtdev_add_device(int phone, sysarg_t id)
 {
 	virtdev_connection_t *dev = (virtdev_connection_t *)
@@ -71,4 +72,5 @@
 
 	dev->phone = phone;
+	dev->id = id;
 	list_append(&dev->link, &devices);
 	
@@ -76,4 +78,24 @@
 	
 	return dev;
+}
+
+/** Find virtual device by id.
+ *
+ * @param id Device id.
+ * @return Device with given id.
+ * @retval NULL No such device.
+ */
+virtdev_connection_t *virtdev_find(sysarg_t id)
+{
+	link_t *pos;
+	list_foreach(pos, &devices) {
+		virtdev_connection_t *dev
+		    = list_get_instance(pos, virtdev_connection_t, link);
+		if (dev->id == id) {
+			return dev;
+		}
+	}
+
+	return NULL;
 }
 
Index: uspace/drv/vhc/devices.h
===================================================================
--- uspace/drv/vhc/devices.h	(revision afc4fbbdd71b68ed8e64f7044745616c69c4628d)
+++ uspace/drv/vhc/devices.h	(revision 6967c1430d08605b85c7be0744903e84cae79ec5)
@@ -45,10 +45,12 @@
 	/** Phone used when sending data to device. */
 	int phone;
+	/** Unique identification. */
+	sysarg_t id;
 	/** Linked-list handle. */
 	link_t link;
 } virtdev_connection_t;
 
-virtdev_connection_t *virtdev_add_device(int);
-virtdev_connection_t *virtdev_get_mine(void);
+virtdev_connection_t *virtdev_add_device(int, sysarg_t);
+virtdev_connection_t *virtdev_find(sysarg_t);
 void virtdev_destroy_device(virtdev_connection_t *);
 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *);
Index: uspace/drv/vhc/hcd.c
===================================================================
--- uspace/drv/vhc/hcd.c	(revision afc4fbbdd71b68ed8e64f7044745616c69c4628d)
+++ uspace/drv/vhc/hcd.c	(revision 6967c1430d08605b85c7be0744903e84cae79ec5)
@@ -69,4 +69,5 @@
 	.interfaces[USBHC_DEV_IFACE] = &vhc_iface,
 	.interfaces[USB_DEV_IFACE] = &hc_usb_iface,
+	.close = on_client_close,
 	.default_handler = default_connection_handler
 };
