Generates a 403 error if the request is not allowed.
If you want to return the error 404 page (page not found), see the function drupal_not_found().
I think this function introduce possibility of confusion usage : This function only render an access denied page but will not stop drupal normal render process.
So, for example, if you want to restrict a node access in a "last chance" test just before displaying it (test implemented in the hook_nodeapi at $op=='view') so you will need to do :
If you do not, drupal will output 2 pages stacked : The access denied page and the page you want to restrict access.
Before look into your solution, I was digging into code and doing a lot of research for this. I was also getting 2 pages issue as you explained and get resolved from your code.
All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.