function custom_logout_menu_item($items, $args) {
    if (is_user_logged_in() && $args->theme_location == 'primary') {
        $logout_link = '<li id="menu-item-9999" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9999">
            <div class="wrap">
                <a href="' . wp_logout_url(home_url()) . '">Disconnetti</a>
            </div>
        </li>';
        $items .= $logout_link;
    }
    return $items;
}
add_filter('wp_nav_menu_items', 'custom_logout_menu_item', 10, 2);