Identify all the Bitcoin core processes, kill those "gracely" and then follow the steps that other users indicated. Your device can not obtain a lock on the folder because another process is using it.
Simply running
bitcoin-cli stop in a terminal will shut it down. No process identification necessary.
Yes, another possibility. I think you should specify the custom datadir for that.
By the way, if I have more than one Bitcoin node running in the same machine, using that command, which node will be stopped?
The daemon which is listening on the RPC port that got the shutdown message.
Lets say that you have two daemons running, A and B, and you have the bitcoin.conf of node A listening on the default ports 8332/8333, and since you can't reuse the same config file for two different nodes (they must have different address/port combos) you set node B to listen on 9332/9333 through another Bitcoin.conf or you just pass those arguments on the command line. If you don't do this then it won't be able to bind the P2P & RPC ports in the first place.
- So you have a particular
bitcoin-cli (possibly from another binary distribution)...
- ...hooked up to a particular RPC server port...
- ...that shuts down the Bitcoind daemon that spawned the RPC server on that port in the first place.