Subscribe to App Shutdown Event

If you want to execute code before the Kit application closes, you can subscribe to the app shutdown event. This will allow you to provide a callback function that is executed when the shutdown event occurs. This is useful for any sort of cleanup code that you want to perform before the app closes.


# Stream where app sends shutdown events
shutdown_stream =

def on_event(e:
    if e.type ==
        print("We are about to shutdown")

sub = shutdown_stream.create_subscription_to_pop(on_event, name="name of the subscriber for debugging", order=0)