The pawn endgame if 40.Qxf8 is a dead draw.
After move 38 it's also a dead draw. Some important elements in queen endgames are the activity of the queen (of course) and a big one is king safety. Sometimes you have an otherwise overwhelming position, but because your king has a lot of space around it (like white after move 38) it's impossible to push the advantage to a win because there will always be perpetual checks.
But black too is a bit airy with only two pawns by his king. Lets say after move 42.Qf4 we remove white's pawn on e5 pawn. Even a passed pawn up I would not be confident of a win as black, in fact I'd suspect it's still something of a dead draw. In that regard white's moves 44.g4 followed by 45.Qxc5 look more like a draw offer than a mistake. (even if he didn't intend it this way )
Here's an example game that comes to mind. In spite of a passed pawn up, black has no way to win due to his king (analyzed in Bronstein's Zurich 1953 book as something of a surprise drawn position even given Keres' amazing endgame skills).
In a recent tournament game my opponent (200 points stronger than me) traded down into a queen and pawns endgame that seemed every so slightly favorable for him. As it's kind of rare to get into this kind of endgame, I was unconfortable, but managed to get a draw after my opponent made a mistake and allowed me to get perpetual check. My question is, what should both sides be planning after move 38? And should white have traded queens or kept them, as he did in the game? How would you judge the resulting endgame if the queens were traded?