Fixed a regression on #255 and covered another case where files are not properly closed #279

Credit goes to Jörg Henne
https://github.com/jankotek/MapDB/pull/279