cmd/syncthing, lib/db: Exit/close db faster (fixes #5781) (#5782)

This adds a 10s timeout on closing the db and additionally cancels active
db iterators and waits for them to terminate before closing the db.
This commit is contained in:
Internal Server Error - Gitea: Git with a cup of tea
500 Internal Server Error

Gitea Version: 1.28.0+dev-477-g8b6ad49a5f