How to ensure job gets finished when app/hangfire gets shutdown?

I would like to use Hangfire to store statistical data to the database every few minutes. I also would like to be able to execute this same job when the web application gets shutdown (e.g. on Dispose?).

I was wondering what the best approach for this? Preferable I would like to block the shutting down of the application until the job has been completed.