[wallet] Close DB on error.
[wallet] Close DB on error.

Ref: https://github.com/bitcoin/bitcoin/pull/11017

I thought better and moved the trivial to another PR.  This will be exclusively the DB change because it is a regression risk.

caraka/gridcoinresearch,caraka/gridcoinresearch,caraka/gridcoinresearch,caraka/gridcoinresearch,caraka/gridcoinresearch,caraka/gridcoinresearch