Praise be to Allah.
The time for Taraaweeh prayer lasts from after ‘Isha’ until dawn comes, so it is valid to perform this prayer at any time during this period.
Al-Nawawi (may Allaah have mercy on him) said in al-Majmoo’:
The time of Taraaweeh prayer begins when ‘Isha’ prayer is over, as was stated by al-Baghawi and others, and it lasts until dawn comes.
But if a man is going to pray in the mosque as an imam leading the people in prayer, it is better to pray Taraaweeh after ‘Isha’ prayer and not to delay it until the middle or the end of the night, so that this will not cause hardship for the worshippers and some of them may sleep and miss the prayer. This is what the Muslims usually do, they pray Taraaweeh after ‘Isha’ and do not delay it.
Ibn Qudaamah said in al-Mughni:
It was said to Imam Ahmad: Will you delay qiyaam – i.e., Taraaweeh – until the end of the night? He said, No, the practice of the Muslims is dearer to me.
But for one who prays Taraaweeh at home, he has the choice: if he wants, he can pray it at the beginning of the night and if he wants he can pray it at the end. And Allaah knows best.