Instead of having Flush optionally shutdown the database and
environment, add a Close() function that does that.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19334 | core#19334]] [1/4]
https://github.com/bitcoin/bitcoin/pull/19334/commits/27b27663849932971eb5deadb1f19234b9cd97ea