Fix closing of database on resource change.