A better way to clean up memory when long running SQL has exception