Answered by Shaykh Rami Nsour
I attend the local masjid for tarawih and witr prayers during Ramadan. But during the last 10 days of Ramadan I prefer to stay awake for more late night prayers and recitation of the Qur’an. By doing so I attend the congregation for tarawih with the Imam and miss out the witr and then perform it late at night. Is this valid?
Answer: If you prefer to pray more than what the Imam leads for taraweeh, you may choose not to pray witr behind him. You would pray witr at the end of the amount of prayers that you perform during that night.
The only time that it is not permissible to skip praying with the Imam, is if he is the regular imam of the place of prayer and is performing an obligatory prayer (fard). The reason for this is to prevent people from feeling as though one is deliberately trying to avoid praying behind the regular imam and thus cause a division (fitna) in the community. [Mukhtasar Khalil]
And Allah knows best.