Synechron Interview Question

How to call a function before a Spring boot application finished? Spring boot shutdown callback