Section 38. All hearings under sections 1 to 38A, inclusive, except those related to court orders to not resuscitate or to withdraw life-sustaining medical treatment for children in the custody of the department under a care and protection order, shall be closed to the general public. It shall be unlawful to publish the names of persons before the court in any closed hearing.