Each opendevice() must eventually be matched by a call to closedevice(). All I/O requests must be complete before CloseDevice(). If any requests are still pending, abort them with abortio(): if (!(CheckIO(InputIO))) { AbortIO(InputIO); /* Ask device to abort request, if pending */ } WaitIO(InputIO); /* Wait for abort, then clean up */ CloseDevice((struct IORequest *)InputIO);