Sometimes the node is still busy while the job is already finished/failed

The node is running:

When you click the #1, the build already failed in this example.

Is there a way to prevent this from happening so that the node is always freed when a build failed or succeeded?
How do we troubleshoot this?

Jenkins setup:

Jenkins: 2.332.1
OS: Linux - 5.4.0-52-generic
Java: 1.8.0_332 - Temurin (OpenJDK 64-Bit Server VM)

aBunchOfPlugins

2.332.1 is an over 3 year old Jenkins version.
Update your Jenkins to latest LTS. Check if the problem persists.
If yes come back here.

I think this was more common in older versions of jenkins, and your version is old with many known security issues. You definitely want to upgrade to the latest LTS and recent plugins to get a better experience and better security.