database open/close fix