How to properly handle NVDEC_THROW_ERROR when NvDecoder crapped out?

Hi, I am building an application using NvDecoder class from to decode H265 stream.

I am using SDK 10.1 on Windows. RTX1050 with driver version 461.09

Everything works great until I need to properly handle NVDEC_THROW_ERROR and close the application gracefully.
In my specific case, I accidentally provided the wrong dimension of the bitstream, and NvDecoder throws an error in NvDecoder::ReconfigureDecoder

My C++ program caught the exception and starts to clean things up. However, no matter how I tried, the program constantly segfault or deadlock in this step of NvDecoder destructor

I’ve also tried feeding an EoS flag to the decoder, like so: DecodeLockFrame(nullptr, 0, &pp_decoded_frame, &num_frame_returned, CUVID_PKT_ENDOFSTREAM); But that also led to a deadlock.

Am I missing something from the documentation? How can I destroy the NvDecoder object properly at this stage?