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() and remove them with WaitIO(). if (!(CheckIO(GameIO))) { AbortIO(GameIO); /* Ask device to abort request, if pending */ } WaitIO((GameIO); /* Wait for abort, then clean up */ CloseDevice(GameIO);