wp_nav_menu add something before closing container and after last list item

I think you can use:

'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s <div class="foo">bar</div> </ul>',

as a wp_nav_menu() argument.

We’re using this part of the wp_nav_menu() function:

$nav_menu .= sprintf( 
    $args->items_wrap, 
    esc_attr( $wrap_id ), 
    esc_attr( $wrap_class ), 
    $items 
);

where the items_wrap argument contains the following sprintf specifiers:

  • %1$s to match the wrap id
  • %2$s to match the wrap class
  • %3$s to match the generated HTML for the items.