Handle app errors and end responses with statusCode 500