Closing of packages and clearing of package DOM