You must guide Karl through each of the forty rooms collecting a key from each.Once forty have been collected you may leave by the exit and open the treasure chest.