The following code will check if a SQL Server Agent job is running and then stop it if it is.
The code can be placed in a SQL Server Agent job and scheduled to run at a suitable time i.e. to ensure a maintenance job is not going to run into business hours.
DECLARE @job_name_to_stop nvarchar(128);
/*only update this line with the name of the job to stop*/
SET @job_name_to_stop = N'long running job name';
IF (SELECT TOP 1 1
FROM msdb.dbo.sysjobs_view a, msdb.dbo.sysjobactivity b, msdb.dbo.syssessions c
WHERE 1=1
AND a.job_id = b.job_id
AND b.session_id = c.session_id
AND c.agent_start_date = (SELECT MAX(d.agent_start_date) FROM msdb.dbo.syssessions d)
AND b.run_requested_date IS NOT NULL AND b.stop_execution_date IS NULL
AND a.name = @job_name_to_stop
) = 1
BEGIN
EXEC msdb.dbo.sp_stop_job @job_name = @job_name_to_stop;
END