1st identify the process it believes is still active. Do a
cat ~/.config/darktable/library.db.lock
it will show the process it seems to see as active. Then do a
ps -ef | grep {process}
or have a look in
/proc/{process}
and see if there is a process running with that id. If there is the lock is correct and you need to track down the process and see what is keeping it active.
The lock file is not removed when the database is not closed in a clean way (like a server crash, power failure. But it could also be a bug). You then need to remove the lock with ...
rm ~/.config/darktable/library.db.lock
but it will instantly get recreated it there is indeed a process active so you should not skip part 1 of the answer before removing the lock.
If the process does not exist and you can create a log where the database was cleanly shutdown but with the lock file not removed you should file a bug report.