More robust cleanup of decoding thread