Andy Daly (who played Ben Franklin) once said on a podcast that the last scene was an improv. Rainn Wilson was just asking questions he thought Dwight would ask, and Daly had read up on Franklin’s Wikipedia page since he knew he might have to improv. It was just a happy accident he knew the info.