rpc: Fix leveldb iterator leak, and flush before `gettxoutsetinfo`

This fixes an iterator leak resulting in

    bitcoind: db/version_set.cc:789: leveldb::VersionSet::~VersionSet(): Assertion `dummy_versions_.next_ == &dummy_versions_' failed."

exception on shutdown (as well as keeping a copy of the utxo data pinned on disk until next restart).

Also make sure to flush pcoinsTip before calling GetStats() to make sure we apply them to the current height.
CCoinsView in general has no means of iterating over the entire dataset, so we're necessarily relying on the lowest level view (the database) which does. I agree it would be nicer if some means of getting a combined resulting view and iterating over it would be nice, but just for GetStats that's not worth it. Also, GetStats is already terribly slow, I don't care about a flush before it.