Fix #1: prevent closing database