C# Excel VSTO add-in - Excel process can't shut down after adding custom task pane RRS feed

  • Question

  • I'm trying to fix the issue in my Excel add-in where Excel gets stuck in the process when my user exits Excel.

    I noticed that the issue starts to happen after adding a CustomTaskPane, then when I try to close Excel, it doesn't exit completely and stays in Task Manager. However if I close Excel before adding the CustomTaskPane, Excel closes properly.

    Here's just a simple code on how I add the CustomTaskPane, it's just a simple blank Task Pane.

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
            var host = new ElementHost();
            host.Dock = DockStyle.Fill;
            var taskPaneControl = new UserControl();
            var taskPaneValue = CustomTaskPanes.Add(taskPaneControl, "My TaskPane");
            taskPaneValue.Visible = true;
    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            Office.CommandBar taskBar = null;
                taskBar = Application.CommandBars["Task Pane"];
                if (taskBar != null)
                    taskBar = null;

    As for the ThisAddIn_Shutdown method, it doesn't matter whether that function is empty or not, Excel still doesn't close properly.

    What's with the issue where Excel does not close properly after adding a CustomTaskPane?

    Please advise, thanks!

    Saturday, August 5, 2017 12:57 PM

All replies

  • Hi deejay220989,

    I failed to reproduce your issue in Excel 2016, could you please tell me the version of your Excel? Including the build number. Have your tried to test it on another computer with a different version of Excel?

    I suggest you try to add the task pane via a button click event on ribbon instead of in the start_up event and then do the test again.

    Have you tried to debug the code? Would ThisAddIn_Shutdown event fire when closing the excel?

    Best Regards,


    Monday, August 7, 2017 9:17 AM
  • Hi Terry,

    I apologize for the late reply, I was working on something else, now I'm back to this.

    I'm using Excel 2013 (15.0.4963.1000) MSO (15.0.4945.1001) 32-bit.

    I've tried on another computer and seeing the same issue, but I have not tried on another version of Excel.

    One thing I noticed. I found this link:, and there's something about slow shutdown for touch-enabled devices. So, I disabled my touch screen driver and now Excel shuts down almost immediately! If I enable back the touch screen driver, it takes like 10-15 seconds to close, and sometimes I have to kill it via Task Manager.

    Wednesday, September 20, 2017 6:25 AM
  • Hi

    I know is an old post. But I'm having the same issue on Excel and cannot find any fix for the issue.

    I've installed the new .NET Framework 4.7.2 and as well the new VSTO (10.0.60825) runtime

    Very appreciated if anyone can help resolve this issue and we have about 50 users have this issue when closing Excel with the VSTO adding using the CustomTaskPane.


    • Edited by Dave.Le Thursday, May 3, 2018 4:40 AM
    Thursday, May 3, 2018 4:26 AM