diff --git a/lib/thinking_sphinx/guard/files.rb b/lib/thinking_sphinx/guard/files.rb
index <HASH>..<HASH> 100644
--- a/lib/thinking_sphinx/guard/files.rb
+++ b/lib/thinking_sphinx/guard/files.rb
@@ -12,6 +12,9 @@ class ThinkingSphinx::Guard::Files
 
     unlocked.each &:lock
     block.call unlocked.collect(&:name)
+  rescue => error
+    raise error
+  ensure
     unlocked.each &:unlock
   end
 
diff --git a/spec/acceptance/indexing_spec.rb b/spec/acceptance/indexing_spec.rb
index <HASH>..<HASH> 100644
--- a/spec/acceptance/indexing_spec.rb
+++ b/spec/acceptance/indexing_spec.rb
@@ -24,4 +24,13 @@ describe 'Indexing', :live => true do
 
     FileUtils.rm path
   end
+
+  it "cleans up temp files even when an exception is raised" do
+    FileUtils.mkdir_p Rails.root.join('db/sphinx/test')
+
+    index 'article_core'
+
+    file = Rails.root.join('db/sphinx/test/ts-article_core.tmp')
+    File.exist?(file).should be_false
+  end
 end
Ensure guardfiles are removed even when an exception is raised