  We perform a long-term simulation of star and disk formation using
three-dimensional non-ideal magnetohydrodynamics. The simulation starts from a
prestellar cloud and proceeds through the long-term evolution of the
circumstellar disk until $\sim 1.5\times10^5$ yr after protostar formation. The
disk has size $\lesssim 50$ au and little substructure in the main accretion
phase because of the action of magnetic braking and the magnetically-driven
outflow to remove angular momentum. The main accretion phase ends when the
outflow breaks out of the cloud, causing the envelope mass to decrease rapidly.
The outflow subsequently weakens as the mass accretion rate also weakens. While
the envelope-to-disk accretion continues, the disk grows gradually and develops
transient spiral structures due to gravitational instability. When the
envelope-to-disk accretion ends, the disk becomes stable and reaches a size
$\gtrsim 300$ au. In addition, about 30% of the initial cloud mass has been
ejected by the outflow. A significant finding of this work is that after the
envelope dissipates, a revitalization of the wind occurs, and there is mass
ejection from the disk surface that lasts until the end of the simulation. This
mass ejection (or disk wind) is generated since the magnetic pressure
significantly dominates both the ram pressure and thermal pressure above and
below the disk at this stage. Using the angular momentum flux and mass loss
rate estimated from the disk wind, the disk dissipation timescale is estimated
to be $\sim10^6$ yr.
