Thank you! I will test that.

The code I found when I googled was short and had a different approach, adding nonce (if I understand correct).
I do not know if this code is better/safer, or if it is working the way I need. Maybe I test both.

 *  Add nonce to logout URL in navigation

function add_logout_url_nonce($items){
  foreach($items as $item){
    if( $item->url == '/wp-login.php?action=logout'){
         $item->url = $item->url . '?redirect_url=/&_wpnonce=' . wp_create_nonce( 'log-out' );
  return $items;


add_filter('wp_nav_menu_objects', 'add_logout_url_nonce');