def connect_on_app_finalize(callback):
 _on_app_finalizers.add(callback)
 return callback

def connect_on_app_finalize ( callback ) : _on_app_finalizers . add ( callback ) return callback
connect callback to be called when any app is finalized .