Execute export diagram svg


I am trying to export the svg of a diagram when the application closes. I have tried the following:

export class FrontendApplicationContributionExtension implements FrontendApplicationContribution {
    @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;

    onStop(app: FrontendApplication): void {;

But nothing happens. No file is exported. When tried to execute the command during initialize() it gives an error: no active handler for this command.
I found ExportSvgCommand within sprotty-theia, but couldn’t figure out a way to utilize this.
Is there a way to export svg of a diagram while closing the application?
Any help would be appreciated.
Thank you.