Add 404 + 500 error handling, close socket when 404 + 500 occurs