Garmin Edge 830 Average power calculation is wrong

I have noticed that when I look at my average power on my edge 830 device and on garmin connect on a bike ride that might be say 2 hours long it will show a number that is significantly higher than the average power if I trim one second off the ride in either Garmin connect.  And the initial average power (i.e. the higher one) is the incorrect.

Any ideas why this is the case?  I keep having to trim my rides by literally a second so see a correct average power in Garmin connect.  Note also that the average power on the device comes across to Training Peaks with the wrong average power and if I trim a second off the ride in training peaks and recalculate I get a number that is lower and the same as the revised number in garmin connect.