When driving in Q1,Q2 and Q3 and you encounter an accident (front wing broken) and you use the menu item "Return to garage", the session ends, no matter how many time remains.
If you damage your car in practice or qualifying, it takes some time to fix the car. So it is not a bug, if the damage is severe enough or you are near the end of the session, it just means there was no time left after the car was repaired.
lol thought I was going mad, I just answered this on the CM forum thinking 'I'm sure I just answered this already', now I realise it is on both forums.