When the user clicks the export button, the request is sent to the server, and the server processes this request until it ends, in your case by email.
Even if the client browser closed after clicking the button, the request was still sent, and the server did not know that the client browser was closed.
Now, usually (when you open the browser throughout the process), the request is sent, and the client expects a response that is returned at the end of processing. This makes sense when you get back a page that tells you what happened, but when your action creates other side effects (like emails), it might seem logical to wait for the client to wait. In this case, consider using an ajax request to send the request, which will ensure that the rest of the page can still interact with the progress of the request.
source share