D3D: some cleanup and a crashfix on shutdown