Minor fixes for closeDatabase