disconnect the user after payment or close the browser

I've used this code in the wordpress functions.php, to disconnect the user after the payment or close the browser.

/ **
* Bypass confirmation of disconnection.
* /
function iconic_bypass_logout_confirmation () {
global $ wp;

if (isset ($ wp-> query_vars['customer-logout'] )) {
wp_redirect (str_replace (& # 39; & # 39; && 39 ;, wp_logout_url (wc_get_page_permalink (& # 39; my account & # 39;)))))
exit;
}
}

add_action (& # 39; template_redirect & # 39 ;, & quot; iconic_bypass_logout_confirmation & # 39;);