What is the meaning of this “forty ways”: (from Carl Sandburg’s Rootabaga Stories)
"We wish a ticket to ride where the railroad tracks run off into the sky and never come back—send us far as the railroad rails go and then forty ways farther yet,"
You shouldn't interpret the number "forty" as a literal metric. It's a figurative, poetic placeholder for an indeterminately large number.
As for "ways"? Gimme the Ax and his children are pulling up stakes and getting a train to go somewhere, anywhere. Not much is going on where they are living, and the only thing the children have experienced is their "ears growing longer".
They are just going to keep going and going until...well, no-one knows when. It could be motivated by wanderlust, dissatisfaction, looking for opportunity, the American pioneer spirit, in any combination. The only reason given?
“It is too much to be too long anywhere,” said the tough old man, Gimme the Ax.
The neighbors speculate on seven such ways:
When their neighbors saw them selling everything they had, the different neighbors said, “They are going to Kansas, to Kokomo, to Canada, to Kankakee, to Kalamazoo, to Kamchatka, to the Chattahoochee.”
Well, actually, eight:
One little sniffer with his eyes half shut and a mitten on his nose, laughed in his hat five ways and said, "They are going to the moon and when they get there they will find everything is the same as it always was."
So, when the ticket agent asks them
"Do you wish a ticket to go away and come back or do you wish a ticket to go away and never come back?"
Gimme the Ax answers with with the quote you're asking about:
"We wish a ticket to ride where the railroad tracks run off into the sky and never come back--send us far as the railroad rails go and then forty ways farther yet."
You can also see this usage in the Bible, (Matthew 18, KJV):
21 Then came Peter to him, and said, Lord, how oft shall my brother sin against me, and I forgive him? till seven times?
22 Jesus saith unto him, I say not unto thee, Until seven times: but, Until seventy times seven.
Update: Hot Licks has mentioned the expression "forty ways from Sunday", which means "in every possible way", and which has dozens of variations catalogued in this other Stack Exchange question. But it's not clear to me that Carl Sandberg has his characters wanting to go everywhere rather than just keep moving.