Prince Harry encouraged young people to speak out if they are feeling lost and isolated at the final event of his UK visit.