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