You're partially correct. The OP's temp being a couple degrees higher than the 40° he thinks it's at shouldn't cause foaming. Higher temps can cause foaming though, and serving at 50° can indeed cause problems.
As I mentioned above, the warmer the beer is, the more the CO2 wants to come out of solution, and the slower and gentler the pour needs to be in order to prevent foaming. The 4-5' lines that most kegerators come with are based on line balancing calculators used for commercial systems, which assume beer temps of 36° or less. If you keep your beer temp at or under 36°, those short lines will typically work fine for carb levels all the way up to ~2.7 vol. If you bump the temp up just a few degrees, to the 38-40° range (like many of us homebrewers prefer), then you need to double the line length to slow things enough to get a decent pour, even with lower carb levels like 2.4-2.5 vol. This is why you see so many suggestions on this site to use 10' lines.