If you want to force the 404.php
template to load if there are no found posts, use the template_include
filter:
function wpa84794_template_check( $template ) {
global $wp_query;
if ( 0 == $wp_query->found_posts ){
$template = locate_template(
array( '404.php', $template ),
false
);
}
return $template;
}
add_filter( 'template_include', 'wpa84794_template_check' );