23 skidoo (sometimes 23 skiddoo) is an American slang phrase popularized during the early 20th century, first attested before World War I and becoming popular during the 1920s. It generally refers to leaving quickly, being forced to leave quickly by someone else, or taking advantage of a propitious opportunity to leave, that is, "getting [out] while the getting's good." The exact origin of the phrase is uncertain.
23 skidoo has been described as "perhaps the first truly national fad expression and one of the most popular fad expressions to appear in the U.S," to the extent that "Pennants and arm-bands at shore resorts, parks, and county fairs bore either  or the word 'Skiddoo'."
Although there are a number of stories suggesting the possible origin of the phrase, none has been universally accepted.
The word skidoo, used by itself as a noun denoting a supposed bringer of bad luck, is attested in the early 1910s, in P.G. Wodehouse's Psmith, Journalist. It appeared in newspapers as early as 1906.
Perhaps the most widely known story of the origin of the expression concerns the area around the triangular-shaped Flatiron Building at Madison Square in New York City. The building is located on 23rd Street at the intersection of Fifth Avenue and Broadway, and, because of the shape of the building, winds swirl around it. During the early 1900s, groups of men would allegedly gather to watch women walking by have their skirts blown up, revealing legs, which were seldom seen publicly at that time. Local constables, when sometimes telling such groups of men to leave the area, were said to be "giving them the 23 Skidoo".
It is at a triangular site where Broadway and Fifth Avenue—the two most important streets of New York—meet at Madison Square, and because of the juxtaposition of the streets and the park across the street, there was a wind-tunnel effect here. In the early twentieth century, men would hang out on the corner here on Twenty-third Street and watch the wind blowing women's dresses up so that they could catch a little bit of ankle. This entered into popular culture and there are hundreds of postcards and illustrations of women with their dresses blowing up in front of the Flatiron Building. And it supposedly is where the slang expression "23 skidoo" comes from because the police would come and give the voyeurs the 23 skidoo to tell them to get out of the area.
An early nickelodeon movie, What Happened on Twenty-third Street, which dates from 1901, shows a woman's skirt being lifted by the updraft from a ventilation grate, exposing her knees.
However, the slang expression "23" was already in use before the Flatiron Building was built (1902), and Webster's New World Dictionary derives skiddoo (with two d's) as probably from skedaddle, meaning "to leave", with an imperative sense.
By the way, I have come upon a new piece of slang within the past two months and it has puzzled me. I just heard it from a big newsboy who had a ‘stand’ on a corner. A small boy with several papers under his arm had edged up until he was trespassing on the territory of the other. When the big boy saw the small one he went at him in a threatening manner and said: ‘Here! Here! Twenty-three! Twenty-three!’ The small boy scowled and talked under his breath, but he moved away. A few days after that I saw a street beggar approach a well-dressed man, who might have been a bookmaker or horseman, and try for the usual ‘touch’. The man looked at the beggar in cold disgust and said: ‘Aw, twenty-three!’ I could see that the beggar didn’t understand it any better than I did. I happened to meet a man who tries to ‘keep up’ on slang and I asked the meaning of ‘Twenty-three!’ He said it was a signal to clear out, run, get away. In his opinion it came from the English race tracks, twenty-three being the limit on the number of horses allowed to start in one race. I don’t know that twenty-three is the limit. But his theory was that ‘twenty-three’ means that there was no longer any reason for waiting at the post. It was a signal to run, a synonym for the Bowery boy’s ‘On your way!’. Another student of slang said the expression originated in New Orleans at the time an attempt was made to rescue a Mexican embezzler who had been arrested there and was to be taken back to his own country. Several of his friends planned to close in upon the police officer and prisoner as they were passing in front of a business block which had a wide corridor running through to another block. They were to separate the officer from the prisoner and then, when one of them shouted ‘Twenty-three,’ the crowd was to scatter in all directions, and the prisoner was to run back through the corridor, on the chance that the officer would be too confused to follow the right man. The plan was tried and it failed, but ‘twenty-three’ came into local use as meaning ‘Get away, quick!’ and in time it spread to other cities. I don’t vouch for either of these explanations. But I do know that ‘twenty-three’ is now a part of the slangy boy’s vocabulary.
However, the number 23 and the word skidoo were already associated with bad luck at least as early as 1899, as seen in this quotation describing an expedition of the Maine Press Club:
The night was spent at Caribou where we arrived late and on the following morning were shown over the town in autos. The little party was here joined by a bunch of late comers bringing the number up to the skidoo hoodoo – 23.
Cartoonist "TAD" (Thomas A. Dorgan) was credited in his obituary in The New York Times during 1929, as being the "First to say 'Twenty-three, Skidoo.'" 
Another source says that baseball player Mike Donlin and comedian Tom Lewis created the expression as part of their vaudeville act.
An article in the June 26, 1906 New York American credits the phrase to one Patsey Marlson, then a former jockey hauled into court on a misdemeanor charge. At his hearing, Marlson is asked by the judge how the expression came about. He explains that when he was a jockey, he worked at a track which only had room for 22 horses to start in a line. If a 23rd horse was added, the long shot would be lined up behind the 22 horses on the front line. Apparently, "23 skidoo" implied that if the horse in the back was to have any chance of winning, it would really have to run very fast. Marlson also says in the article that the expression was originally "23, skidoo for you."
It may be from a parody of Henry Miller's well-regarded stage presentation of Charles Dickens's novel A Tale of Two Cities. Miller's 1899 production, entitled "The Only Way," was staged at the Herald Square Theatre. The final scene of the play portrays a series of executions at a guillotine. As each person is beheaded, an old woman counts. When Sydney Carton, the protagonist of the story, is beheaded, the old woman calls out "Twenty-three!" The grisly scene was remarkable for its time, but it soon became the subject for parody, and the phrase "Twenty-three, skidoo!" was used by Broadway comedians to parody this moment. This seems likely to be an instance of comedians using an already-popular slang juxtaposed against a well-known dramatic moment for the resulting comic effect, and not an indication of invention, although the theatrical usage may have popularized the expression, or made it more widely known.
It is said that 23 was an old Morse code signal used by telegraph operators to mean "away with you." (The same story accounts for 30 as "end of transmission", a code still used by modern journalists, who place it at the end of articles as a sign to editors. However, the Western Union92 Code, which is the source of 30 and other numbers like 73 and 88 still used in amateur radio, lists 23 as "all stations copy".)
An early 1900s Death Valley town had 23 saloons (many basically tents). A visit to all, going 23 skidoo, meant having a very good time.
Death Valley National Park Service interpreters have sometimes given as an explanation that the early 1900s mining town of Skidoo, California required that a water line be dug from the source of water on Telescope Peak to the town—a distance of 23 miles. Most thought it would be easy, but the immensely hard rock along the course made it very difficult; it was eventually accomplished by a determined engineer. The term "23 Skidoo" was then used as a statement of irony, something like "duck soup": a reference to something apparently easy, but actually very difficult.
It may harken back to a jump rope rhyme that ended up "butterfly, butterfly, twenty three to do" which dates to 1909.
In The Literature of Slang (p. 38), W.J. Burke claims that the term "skidoo" was coined in 1906 by the musical comedy star Billy B. Van, citing an article in the Indianapolis Morning Star, March 31, 1906.
From the book, The Age of Uncertainty, by J. K. Galbraith (Houghton Mifflin, 1977), Skidoo 23 refers to the abandonment of a town, Skidoo, in the Panamint mountains of California in the early 1900s. The number 23 apparently refers to the number of miles water had to be piped to the town and its sole reason for being; the mining of gold. After the mines were depleted, the town ceased to exist.
In the book, The Confessions of a Con Man as Told to Will Irwin, by Will Irwin (B. W. Huebsch (New York) 1913), 23 relates to a rigged dice game called a cloth that traveled with small American circuses and carnivals in the latter part of the 19th Century. It referred to a square marked 23 You Lose on the cloth which had 48 printed squares but only the one You Lose square. After making a big bet, the sucker was at some point persuaded that he had rolled a 23, had thereby lost his money, and should stop squawking and beat it. This became, by a logical extension, an in-crowd, underworld expression indicating that for whatever reason the person addressed would not get what he was seeking and should clear out. The full text of Irwin's book (illustrated by William Glackens of the Ashcan School) is available at archive.org).
He took Mother for a ride in his first automobile.... As Dad and Mother, dressed in dusters and wearing goggles, went scorching through the streets of Boston, bystanders tossed insults and ridicule in their direction.... "Get a horse. Twenty-three skidoo."
^Benecke, Mark (2011). "The Numerology of 23". Skeptical Inquirer (Committee for Skeptical Inquiry) 35 (3): 49–53.
^Douglas, George H. (2004). Skyscrapers: A Social History of the Very Tall Building in America. McFarland and Co. ISBN0-7864-2030-8. p. 39 "The intersection in front of the [Flatiron Building] was always a congested spot, and a windy one, too, and in the old days the corner was a famous spot for young lads to watch women's skirts being whipped around. So famous was the spot, in fact, that policemen would occasionally have to shoo away these perpetual watches, and the expression 'Twenty-three Skidoo' was said to have been born on this windswept corner."
^"'Tad,' Cartoonist, Dies In His Sleep.". New York Times. May 3, 1929. "Thomas A. Dorgan, Famous For His 'Indoor Sports,' Victim of Heart Disease. Was A Shut-In For Years. Worked Cheerfully at Home in Great Neck on Drawings That Amused Countless Thousands. His slangy breeziness won immediate circulation. It was he who first said 'Twenty-three, Skidoo,' and 'Yes, we have no bananas,' 'apple sauce' and 'solid ivory.' Other expressions that are now part of the American vernacular include 'cake-eater,' 'drug-store cowboy,' 'storm and strife,' 'Dumb Dora,' 'dumb-bell,' 'finale hopper,' 'Benny' for hat and 'dogs' for shoes."|accessdate= requires |url= (help)
^Mansch, Larry D. (1998). Rube Marquard: The Life & Times of a Baseball Hall of Famer. McFarland and Company. ISBN0-7864-0497-3.p. 96, "Lewis sat on Mike's lap and acted as a dummy to Mike's ventriloquist. The pair first came up with the expression 'twenty-three skidoo.'"