The Unload routine performs any operations that are necessary before the system unloads the driver.
VOID
XxxUnload(
IN PDRIVER_OBJECT DriverObject
);
None
A driver's Unload routine executes in a system thread context at IRQL = PASSIVE_LEVEL.
The Unload routine is optional. A driver's Unload routine, if supplied, should be named XxxUnload, where Xxx is a driver-specific prefix. The driver's DriverEntry routine must store the Unload routine's address in DriverObject->DriverUnload. (If no routine is supplied, this pointer must be NULL.)
For detailed information about implementing a driver's Unload routine, see Writing an Unload Routine.