Sorry I don't have a specific answer for you but I have had this happen before and it is really frustrating. What I can say is that when it did happen, I ended up letting it record well past the last bit of audio before stopping to make sure it was captured. However, there was no known latency factor to figure out how long.
My guess was it had to do with the computer itself and sound card settings - at that time I was using an M-Audio 2496. I didn't have this problem on other computers.