When a person is nearing death, he needs good javana cittas (wholesome impulses) about half an hour in advance. If these kusala though processes prevail till the last breath, the being will be reborn in happy abodes. If he has akusala javana cittas (unwholesome impulses) before death, he will be reborn in woeful abodes. Just as the finishing lap is important for a racing horse, the final consciousness is of great importance to any living being. Whether a person receives good or bad thoughts depends on the object of mind called arammana.
ref: http://dhammacitta.org/forum/index.php/topic,22545.0.html (http://dhammacitta.org/forum/index.php/topic,22545.0.html)