Fixing not closing persistence if persistence was created