Tsar Nicholas II was placed under house arrest by the Provisional Government at Tsarskoe Selo less than a week after he abdicated, on 2 March 1917 (old style). He and his family thus never had a chance to flee Russia.
The decision was made by the Justice Minister Alexander Kerensky and Foreign Minister Pavel Milyukov. They had three reasons for this decision.
Firstly, Milyukov and the Kadets feared that angry mobs might storm Tsarskoe Selo and lynch the Tsar - so the arrest was to preserve his life. The Kadets had only ever wanted a constitutional monarchy - the chaos of the February Revolution made them fear the revolution might spiral out of control into a class struggle between the propertied and propertyless classes. Their top priority was therefore to arrest the radicalisation of the revolution.
Secondly, arresting the Tsar was a key demand of the newly created Petrograd Soviet, as the workers and soldiers in the capital blamed the Tsar personally for their hardships. This is unsurprising; Nicholas was an autocrat and claimed personal rule over Russia, which naturally meant he would be personally blamed for everything from scandals (e.g. alleged affairs between the Tsarina and Rasputin), atrocities (e.g. the shooting of 50 protesters demanding bread and peace in Znamenskaya Square on 26 Feb 1917) and defeats in war (more than 5 million men had been killed, wounded or captured since the outbreak of war in 1914). The Provisional Government, as War Minister Guchkov admitted in an April letter "has no power" and was dependent on the consent of the Petrograd Soviet to rule "insofar as it controls the organs of real power: the telegraph, the railway lines" and the sympathy and support of the common soldiers.
Thirdly, the Provisional Government ministers were mostly Fourth Duma delegates committed to a vision of a liberal democratic Russia. This meant that they had to, at some point, come up with a plan to try the Tsar for his alleged crimes against the Russian people.
These reasons led to Nicholas' swift arrest. He spent March to July 1917 under house arrest in Tsarskoe Selo (his personal residence, 25km outside Petrograd). He was moved to the provinces after the riots of the July Days, but remained under house arrest for the following year, as the Bolsheviks seized power and the civil war broke out. Both the Provisonal Government and the Bolsheviks deferred making a decision on what to do with the Tsar- vague plans to exile him or put him on trial were explored, but never seriously put into action. Both the Provisional Government and subsequent Soviet Government were too preoccupied with more urgent and pressing concerns, like WW1 and food shortages. By mid 1918, the advance of Kolchak's Siberian Army across the Urals forced Lenin's hand. Fearing the Tsar would be captured by counter revolutionary forces, Lenin ordered his execution in July 1918.
Principal sources:
Orlando Figes, A People's Tragedy
Richard Pipes, A Concise History of the Russian Revolution
Robert Service, A History of Modern Russia