OfficeJs Excel Addin Shutdown event

OfficeJs Excel Addin Shutdown event



 Jul 10 2022
1 Comments (1 New)

I would like to have an Excel OfficeJS add-in shutdown event so that I can immediately abort JavaScript background operations and so that excel will then immediately exit.

Using a background signalR connection with the shared runtime enabled, I noticed that the excel process no longer immediately terminates for me after closing excel.  It takes about 2 minutes or something before it seems excel realizes it should kill the JavaScript runtime.

When its not in shared runtime mode, it is shutting down immedaitely so thats why im thinking its something to do with signalr since I know its still running, but my timers aren't.


If I launch the edge debugger window and after closing excel I can see signalr is still running, running clear and set timer calls even though my timers do not work.


Any webpage with a persistent signal R or other persistent connection to web servers would have this problem I think, and this seems like a significant limitation for more interactive web add-ins.


Relaunching Excel another time while another is still shutting down causes all sorts of troubles for add-ins - addins won't load at all etc, so this is something we can't really let happen for our software because it appears that something is broken.


In non shared runtime mode, each side bar gets its own window so I'm able to shutdown signalr on the window unload events.

Unfortunately, this doesn't get fired in the shared runtime mode.


Is there any plan to add a shutdown event at all or is there any other event I could listen to?

I would use a close workbook event if there was one or any other alternative.


In shared runtime mode, is exiting excel supposed to terminate the js runtime immediately?

It seems to be stopping my own timers, but it seems not to be able to shutdown SignalR, or for some other reason its not shutting down.


The shared runtime is generally a much better experience for the user, but this limitation is stopping us from being able to switch over at the moment.


Thank you very much!

Brass Contributor

I just tried to use a timer to see if I could get a helpful error when inspecting the workbook.


Some of the time I'm getting an exception, which I could use to shutdown SignalR but even then its not terminating the runtime.

The other times my timers never run so I never get a chance to try to terminate SignalR.