After the device is closed, you must deallocate the I/O request memory. The exact method you use depends on how you allocated the memory in the first place. For allocmem() you call freemem(), for createextio() you call deleteextio(), and for createiorequest() you call deleteiorequest(). If you allocated the I/O request memory at compile time, you naturally have nothing to free. Finally, you must delete the message port you created. You delete the message port by calling deletemsgport() if you used createmsgport(), or deleteport() if you used createport(). Here is the checklist for gracefully exiting: * Abort any outstanding I/O requests with abortio(). * Wait for the completion of any outstanding or aborted I/O requests with waitio(). * Close the device with closedevice(). * Release the I/O request memory with either deleteiorequest(), deleteextio() or freemem() (as appropriate). * Delete the message port with deletemsgport() or deleteport().