Apparently medical measurements are detecting unusually high activity in brains of people around their time of death. This seems contradictory and is said to be puzzling researchers since the body is shutting down. Wondering if there might be an explanation in Buddhism.
The sutta that comes to mind is Pāyāsi DN23, although it probably doesn’t answer the question you raise.
In other spiritual traditions like Yoga, Kaula and Shaiva Tantra, etc., there is meditation that directs consciousness to the head, to the Ajna chakra or the crown Sahasrara chakra, to have spiritual experiences connected with the pineal gland.
In Tibetan Buddhism Vajrayana, there is also the practice of Phowa (Tibetan: འཕོ་བ་, Wylie: 'pho ba, Sanskrit: saṃkrānti), described as ‘transference of consciousness at the time of death,’ ‘mindstream transference,’ ‘the practice of conscious dying,’ or ‘enlightenment without meditation’ (Wylie: ma-sgom sangs-rgyas). It’s where you practice directing your consciousness at the moment of death to the crown of the head and the fontanelle, Brahmarandha, to achieve a higher rebirth, because what is carried into the next reincarnation can leave the body more easily.
In Yoga there is the practice of Parakāyapraveśa literally means ‘entering into another’s body’. The Yogasutras of Patañjali describes parakāya praveśa or ‘entering’ into the body of another person dead or alive as one of the yogasiddhis or occult powers gained by a yogi who has succeeded in attaining samādhi. Every person is imprisoned as it were in the physical body due to the prārabdha-karma. A yogi who has attained the saiyama state has developed enough power to detach his mind from his own body and enter into the body of another person, dead or alive, and work through it. This is called parakāyapraveśa.
The pineal gland in the brain also plays an important role. There are some meditations and body and breathing exercises that focus on influencing the pineal gland in the head, since it affects the release of melatonin and serotonin. There is also a theory that the pineal gland produces DMT (dimethyltryptamine) during the dying process, which also influences the visual phenomena in the dying process or during near-death experiences or out-of-body experiences. The pineal gland is also connected with the descriptions of Amrita nectar.