Fixed calling of LogDatabase to close() finally