I believe the engine simulates the score/stats, and then posts a play-by-play to accurately show all of the stats and such that happened. So I don't believe that the 'fouls' at the end of games effect the outcome of your team, seeing as they would have lost anyway.
However, it is the worst feeling when the you see your up 1 with five seconds and lose because your best defensive player committed a shooting foul.. I know all too much about that one