how do they take crane off top of building?
Commonly cranes attached to the top of buildings were built up there.
Giant crane is used helicopter to lift it up and bring it down from very tall building.
Depends on the building. Either a taller crane is brought in to lift them, or they're lifted by helicopter. And sometimes a building effectively builds itself, and the crane moves up with the construction platform after being constructed at ground level. Will still need a helicopter to remove it of course.