Never mind I solved it:
Now just call NotFound() wherever you need provided that the output hasn't already started which shouldn't be a problem because it is always better to do all the checking before starting the output.
$contents = ob_get_contents();
Header('HTTP/1.1 404 Not Found');
Header('Cache-Control: no-store, no-cache');