An 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(KeyIO)))
{
AbortIO(KeyIO); /* Ask device to abort request, if pending */
}
WaitIO(KeyIO); /* Wait for abort, then clean up */
CloseDevice(KeyIO);