Stopping multiple server side SQL Server traces immediately A mistake in an audit script generated more than 100 traces. Is there a way I can stop all of them?
Below are a couple of T-SQL examples that will stop and delete server-side SQL traces or Extended Event traces you can customize for your particular situation.

SQL Trace:

DECLARE @sql nvarchar(MAX) = (
    SELECT 'EXEC sp_trace_setstatus ' + CAST(id AS varchar(10)) + ', 0;
EXEC sp_trace_setstatus ' + CAST(id AS varchar(10)) + ', 2;
'
    FROM sys.traces
    WHERE path LIKE '%\yourtracefilenamepattern%.trc'
    ORDER BY id
    FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)');
PRINT @sql;
--EXEC(@sql);


Extended Event trace:

DECLARE @sql nvarchar(MAX) = (
    SELECT 'ALTER EVENT SESSION ' + QUOTENAME(name) + ' ON SERVER STATE = STOP;
DROP EVENT SESSION ' + QUOTENAME(name) + ' ON SERVER;
'
    FROM sys.dm_xe_sessions
    WHERE name LIKE '%yourtracenamepattern%'
    ORDER BY name
    FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)');
PRINT @sql;
--EXEC (@sql);