Close certain tyk rest endpoint for external traffic

How can one close a endpoint in tyk rest api for external traffic. I am trying to do it by creating a pre middileware and then checking if the endpoint /oauth/token is accessible form debug console. It throws an 404 error. But when i use the endpoint from command line curl using the client id and the secret then the access token is returned. How can one bubble an error from preauth middleware to disallow running of further middlewares.