(a) Whenever both parents of a minor are deceased, visitation rights shall be granted to the grandparents of the minor who are the parents of the minor's legal parents unless it is shown that such visitation would be detrimental to the best interests and welfare of the minor. In the discretion of the court, reasonable visitation rights may be granted to any other relative of the minor or other person having an interest in the welfare of the child. However, the court shall not grant visitation privileges to any person who otherwise might have visitation privileges under this Section where the minor has been adopted subsequent to the death of both his legal parents except where such adoption is by a close relative. For the purpose of this Section, "close relative" shall include, but not be limited to, a grandparent, aunt, uncle, first cousin, or adult brother or sister. Where such adoption is by a close relative, the court shall not grant visitation privileges under this Section unless the petitioner alleges and proves that he or she has been unreasonably denied visitation with the child. The court may grant reasonable visitation privileges upon finding that such visitation would be in the best interest of the child.
An order denying visitation rights to grandparents of the minor shall be in writing and shall state the reasons for denial. An order denying visitation rights is a final order for purposes of appeal.