Certain highly advanced teachers, such as Padmasambhava, were believed to advanced to a rainbow body while still living.
At this stage, when one is near death one give attention to light that emanates from around one’s fingers, after one’s body transfers into a light body.