I accidentally created an immortal ghost task in the terminal and I can't kill it

I’m using node.js, vite, react and an express server. I’m also using a few other packages but those are the one’s that I feel are most important.

I created a task in tasks.json for a build and run command which runs npm run build; node server/server.js in the terminal.

Everything was working fine. I could start the task with cmd + shift + b and stop it with ctrl + c. But then I wanted to see if the server would continue to run if I closed the workspace’s tab, and it did.

But then I opened the workspace again and I couldn’t see anything in the terminal. Pressing ctrl + c didn’t stop the server.

I tried googling the issue. One of the results told me to press cmd + shift + p and writing terminate task, and when I did, it said no tasks were running. Even though going to the weburl loaded the page, and it said that the port was being used. I tried asking gemini which told me to run the hard reset command and I did, but it still didn’t kill the process. I reloaded the workspace, closed all open terminal tabs, tried to run the build and run command again on the same port (which gave the error that the port was already in use), deleted tasks.json and even tried coming back about an hour later and it was still running.

How do I stop the server :sob:

Update:
The server seems to turn off by itself after a few hours and I also found out how to kill the ghost task. If anyone else has the same issue:

Use ps aux | grep node to print all the running node processes to the terminal, then look for the process ID of the process you want to kill (the ID will be in the second column, see image for reference. In my case the ID was 3607)

Then run kill -15 process_id

Source