Fix #2581 Close WAL when DB is closing
Merge pull request #2591 from PhantomYdn/fix-closing-wal

Close WAL when DB is closing
Merge with 1.7.7 branch.