When an application is about to close, it should destroy all DirectInput objects. This is a three-step process.
For a sample function that closes down the DirectInput system, see Tutorial 1 Samples.