How to kill a docker process that is in docker run -v /var/run/docker.sock:/var/run/docker.sock

I am spawning a child processes in node that runs a bash script with docker run/build inside of it but can’t seem to stop the processes in any way.

let buildScript = “docker build -t " + image_name + " . \n”;
buildScript += “docker run -v /var/run/docker.sock:/var/run/docker.sock " + image_name + " \n”;
buildScript += “docker rmi " + image_name + " \n”;
const dockerBuild = spawn(‘bash’, [’-c’, buildScript]);

I would like to be able to kill the docker build / run when a user clicks cancel build. I have successfully killed the node process but the docker processes still run. I have tried docker stop and docker kill but I think the socket ‘-v /var/run/docker.sock:/var/run/docker.sock’ is messing me up. Any help would be great thank you!

I am running on a Mac OS 10.15.7
Docker version is
Client:
Cloud integration: 1.0.17
Version: 20.10.7
API version: 1.41
Go version: go1.16.4
Git commit: f0df350
Built: Wed Jun 2 11:56:22 2021
OS/Arch: darwin/amd64
Context: desktop-linux
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:54:58 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.6
GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc:
Version: 1.0.0-rc95
GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
docker-init:
Version: 0.19.0
GitCommit: de40ad0