A protostellar cloud will continue to collapse as long as the gravitational binding energy can be eliminated.
When the surrounding gas and dust envelope disperses and accretion process stops, the star is considered a pre-main sequence star (PMS star).