fix closing database in core package