diff --git a/ILSpy.AddIn.Shared/ILSpyAddInPackage.cs b/ILSpy.AddIn.Shared/ILSpyAddInPackage.cs
index 195940b68..14f3f9227 100644
--- a/ILSpy.AddIn.Shared/ILSpyAddInPackage.cs
+++ b/ILSpy.AddIn.Shared/ILSpyAddInPackage.cs
@@ -97,6 +97,24 @@ namespace ICSharpCode.ILSpy.AddIn
 			OpenReferenceCommand.Register(this);
 			OpenCodeItemCommand.Register(this);
 		}
+
+		protected override int QueryClose(out bool canClose)
+		{
+			var tempFiles = ILSpyInstance.TempFiles;
+			while (tempFiles.TryPop(out var filename))
+			{
+				try
+				{
+					System.IO.File.Delete(filename);
+				}
+				catch (Exception)
+				{
+				}
+			}
+
+			return base.QueryClose(out canClose);
+		}
+
 		#endregion
 
 		public void ShowMessage(string format, params object[] items)
diff --git a/ILSpy.AddIn.Shared/ILSpyInstance.cs b/ILSpy.AddIn.Shared/ILSpyInstance.cs
index c5ebb897e..f43f9552c 100644
--- a/ILSpy.AddIn.Shared/ILSpyInstance.cs
+++ b/ILSpy.AddIn.Shared/ILSpyInstance.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
@@ -20,8 +21,9 @@ namespace ICSharpCode.ILSpy.AddIn
 
 	class ILSpyInstance
 	{
-		readonly ILSpyParameters parameters;
+		internal static readonly ConcurrentStack<string> TempFiles = new ConcurrentStack<string>();
 
+		readonly ILSpyParameters parameters;
 		public ILSpyInstance(ILSpyParameters parameters = null)
 		{
 			this.parameters = parameters;
@@ -55,6 +57,8 @@ namespace ICSharpCode.ILSpy.AddIn
 				string filepath = Path.GetTempFileName();
 				File.WriteAllText(filepath, assemblyArguments);
 
+				TempFiles.Push(filepath);
+
 				argumentsToPass = $"@\"{filepath}\"";
 			}