A driver should close a device only after all applications have finished using it. You might want to ignore the DRV_CLOSE command (just return with a nonzero return value) if the application that caused it to be sent is not the only one still using the driver.
Often, all of the steps required to close a device can be handled when a driver processes the MCI_CLOSE_DRIVER command. In such cases the driver can simply return a nonzero value when DRV_CLOSE is received.