Sidebar showing up at bottom of pages

I’ve made some custom templates in my theme, and I have them in the config.php file as follows to remove the primary sidebar from them. However, at the bottom of each page the primary sidebar content is showing up after the end of /main. Any ideas? The only way I’ve been able to remove it has been to have no content in the primary sidebar, and it is happening on templates that have a custom sidebar i made pulled and the regular templates as well (I’m a bit of a beginner on roots, so my apologies if it’s just me being dumb):

function roots_display_sidebar() {
  $sidebar_config = new Roots_Sidebar(
    /**
     * Conditional tag checks (http://codex.wordpress.org/Conditional_Tags)
     * Any of these conditional tags that return true won't show the sidebar
     *
     * To use a function that accepts arguments, use the following format:
     *
     * array('function_name', array('arg1', 'arg2'))
     *
     * The second element must be an array even if there's only 1 argument.
     */
    array(
      'is_404',
      'is_front_page'
    ),
    /**
     * Page template checks (via is_page_template())
     * Any of these page templates that return true won't show the sidebar
     */
    array(
      'template-custom.php',
      'template-home.php',
      'template-postpage.php'
    )
  );
  return apply_filters('roots_display_sidebar', $sidebar_config->display);
}

Seems you might need to use is_page_template('template-custom.php') as your array elements.

The second array is automatically checked against is_page_template so what you’ve done seems fine.

I take it you’re using custom page templates and selecting them through the WordPress dashboard? The is_page_template conditional will only work on the main template (selected manually or via the template hierarchy), not on templates included by other templates.

Can you also check if using template-custom.php removes the sidebar?

If you’re using custom loops make sure you reset the query afterwards or it prevent the conditionals from working.

Thank you so much for the feedback! I had a reset query issue floating around in some custom type loops that I added, the array seems to be working as it was in there.

If you have a page template that calls in dynamic post data then the sidebar will show.

I can’t seem to turn the sidebar off with the various conditionals mentioned here.

Do you have any other ideas?

EDIT
I just realized you gave the solution @Foxaii - thanks.

Adding wp_reset_query(); at the end of my php got rid of the unwanted sidebar.