A (regular) long rest is 8 hours or longer
The general rules for resting specify that 8 hours is the minimum time required for a long rest (emphasis added):
A long rest is a period of extended downtime, at least 8 hours long, [...]
At the end of a long rest, a character regains all lost hit points. The character also regains [...]
So, if for some reason the party wanted to take a long rest that lasted 10 hours, technically the rules allow for this, and things that happen at the end of a long rest would happen at the 10 hour mark, when the party ends their rest. Of course, there is generally no mechanical benefit to extending a rest in this way, although I'm sure there are contrived situations where it could be useful.
A long rest via trance is exactly 4 hours long
The elf race's Trance feature does not appear to allow for the same flexibility (emphasis added):
Elves don’t need to sleep. Instead, they meditate deeply, remaining semiconscious, for 4 hours a day. [...] After resting in this way, you gain the same benefit that a human does from 8 hours of sleep.
There is no provision here for extending your rest. After 4 hours of trancing, you gain the equivalent benefit of 8 hours of sleeping, which is sufficient to complete a long rest. Nothing stops you from continuing your meditation, but you don't gain any mechanical benefit after the 4-hour mark.
As others have pointed out, if your main concern is having your daily abilities recharge at the same time as the rest of the party, all you need to do is begin your trance 4 hours before the end of everyone else's long rest.
Recovery of limited-use abilities is an edge case
Every limited recoverable resource in the game (including spell slots) generally has a specific trigger for when it recharges, and when that trigger occurs, the recharging occurs instantaneously. Of course this is not a good approximation for real life, but it is a necessary sacrifice of realism in favor of mechanical simplicity in order to make the game playable using pen and paper. This results in weird edge cases: if the party is attacked 5 seconds before their long rest is complete, they are still tapped out from the previous adventuring day. If they are attacked 5 seconds after their long rest is complete, they are fully healed and recharged. There's no logical reason why that 10 seconds should make such a large difference, but mechanically it does. This is an edge case inherent in the discrete nature of these resources: they are either recharged and ready to use or they are not. In a video game, you could imagine replacing spell slots with a mana bar that gradually and continuously recharges while you are resting. This would eliminate the edge case, but it's just not practical to implement this with pen and paper.
Given that such edge cases are inherent to the design of 5e and most other TTRPGs, the best advice I can give is that the DM should simply avoid pushing on these sharp edges. If you're going to have bandits ambush the party while they're camping, just make sure it never happens near the 8-hour mark. Have it either happen well before or well after the completion of the long rest, and you'll never need to deal with the issue (as long as the elf in the party times the start of their trance properly, that is).