The NVENC session was destroyed before its child resources
(textures, surfaces) were cleaned up, causing resource cleanup
calls to operate on an invalid session handle.
Reorder destruction to free all registered resources before
destroying the encoder session.