diff --git a/gfx/skia/src/gpu/GrContext.cpp b/gfx/skia/src/gpu/GrContext.cpp
index 145230fe4490ed7be42cc789fb5d41e0c9c7b30e..f13f6f5e35a5531dbdbccf322047e477ae6b9355 100644
--- a/gfx/skia/src/gpu/GrContext.cpp
+++ b/gfx/skia/src/gpu/GrContext.cpp
@@ -136,12 +136,12 @@ int GrContext::GetThreadInstanceCount() {
 }
 
 GrContext::~GrContext() {
+    this->flush();
+
     for (int i = 0; i < fCleanUpData.count(); ++i) {
         (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
     }
 
-    this->flush();
-
     // Since the gpu can hold scratch textures, give it a chance to let go
     // of them before freeing the texture cache
     fGpu->purgeResources();