C# Grasshopper Component Application Shutdown Hook/Event

Hopefully a very easy question, how do I hook into an application shutdown event inside a component’s code?

There are some tasks it needs to do before quitting a session, but only upon quitting.

Is there a

public override void OnBeginShutdown

like in Excel or

public Result OnShutdown(UIControlledApplication application) {
    application.ControlledApplication.DocumentOpened -= OnDocOpened;
    //Rest of your code here...
    return Result.Succeeded;

like in Revit?

Thank you,



Thanks, will try it out.