How Do I Set a 404 Error in PHP and have the Bricks 404 Error Page show?

I tested it on another site with Elementor and its 404 error template is displayed. For example I usually disable access to the uncategorized Category taxonomy in WordPress if I do not use posts with the following code snippet.

<?php 
// For example: https://domain.com/category/uncategorized/
// If not using Category Taxonomy deleting of Uncategorized Category not possible

function ess_disable_uncategorized_category_archives() {

    // if we are on Uncategorized category archive page
    if (is_category('uncategorized')) {
        global $wp_query;
        $wp_query->set_404();
        status_header(404);
    }

}

// Disable access
add_action( 'template_redirect', 'ess_disable_uncategorized_category_archives' );

This snippet when using Elementor and their Hello theme will return the 404 error template that I created.

This same snippet in Bricks does not return my custom 404 template.

I also disable the Author archive using a similar code snippet. It also has the same problem in Bricks but not with Elementor.