URL to properly shutdown current program and return XML result to browser



I would like to be able to trigger a “/quit” URL that would halt the currently running program and at the same time would display a nice XML (or anything else) result on the browser / program that has triggered the url.

The stop part is working of course fine, but i don’t see how to easily defer the exit after the processing by echo.

I’ve seen the cookbook here : https://echo.labstack.com/cookbook/graceful-shutdown
but i’m not even sure this fills the same need (and anyway would prefer to not rely on additional wrapper like grace/graceful)

Any idea about the “logic” that i could put in place for such a case ?
Thanks in advance.