Depending on your site setup, users may need to confirm they want to log out, which some may not consider the best user experience. Use the code snippet below to allow the user to log out without being prompted for a confirmation.
PHP
function wc_bypass_logout_confirmation() {
global $wp;
if ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
exit;
}
}
add_action( 'template_redirect', 'wc_bypass_logout_confirmation' );