tokenManager.on('expired', callback): page redirected before callback finishes

I need to call a api when the token expires. Angular Snippet:

notifySessionTimeout(): void {
        this.oktaAuth.tokenManager.on('expired', (key, expiredToken) => {
            this.http
            .post(url, null)
            .pipe(catchError(this.errorNotify.handleServerError('notify session timeout')))
            .subscribe( val => console.log(val));
        });
}

However, the page is redirected before the API call finishes and subscribe block is not called. What should I do to make the API call before page is redirected to logout URL.

I am using npm package “@okta/okta-angular”: “3.0.1”