ead513
diff --git a/src/dec/idec_dec.c b/src/dec/idec_dec.c
ead513
index a371ed7..258d15b 100644
ead513
--- a/src/dec/idec_dec.c
ead513
+++ b/src/dec/idec_dec.c
ead513
ead513
@@ -283,10 +283,8 @@
ead513
 
ead513
 static VP8StatusCode IDecError(WebPIDecoder* const idec, VP8StatusCode error) {
ead513
   if (idec->state_ == STATE_VP8_DATA) {
ead513
-    VP8Io* const io = &idec->io_;
ead513
-    if (io->teardown != NULL) {
ead513
-      io->teardown(io);
ead513
-    }
ead513
+    // Synchronize the thread, clean-up and check for errors.
ead513
+    VP8ExitCritical((VP8Decoder*)idec->dec_, &idec->io_);
ead513
   }
ead513
   idec->state_ = STATE_ERROR;
ead513
   return error;
ead513