When ngx.exit using OpenResty precede it with return

It is recommended than when using ngx.exit precede it with return to reinforce the fact that request will end.

Few notes from Yichun Zhang about it:

Also note that this method call terminates the processing of the current request and that it is recommended that a coding style that combines this method call with the return statement, i.e., return ngx.exit(...) be used to reinforce the fact that the request processing is being terminated.  
When being used in the context of header_filter_by_lua, ngx.exit() is an asynchronous operation and will return immediately. This behavior may change in future and it is recommended that users always use return in combination as suggested above.