beforeunload event and Content-Disposition=attachment

I recently add on my code something like this:

$(window).on('beforeunload', function () {
    $('.whirly-loader').show(); //SPINER
})

So anytime the user go to another side of my web the spinner show up. And it works most of the time.
But, in some part of the app the client start going another side and the server response with this headers:

Cache-Control
    max-age=0, must-revalidate, private
Connection
    Keep-Alive
Content-Disposition
    attachment;filename=suministro.csv
Content-Type
    text/csv; charset=utf-8
[...]

This prevents the reload of the page and only show up the window to ask to download or open the document.
My problem is the spinner still show up even if the page stop load

Which should be the event to hide my spinner even if the page don’t reload because of the headers?