Final answer:
A protostar begins to retain its heat when it becomes dense enough to trap infrared radiation. This slows down the protostar's collapse and its surface temperature starts to rise, leading to further stages of stellar evolution.
Step-by-step explanation:
When a protostar begins to retain its heat, it marks a crucial shift in its evolutionary track. This occurs when the protostar becomes dense and opaque enough to trap the heat released by gravitational contraction, causing the rapid collapse to slow down. The outer layers' inward fall diminishes as gas pressure builds due to the increased temperature and retained heat. The result is a slow contraction of the protostar, with its surface temperature rising as it moves to the left on the Hertzsprung-Russell (H-R) diagram, which plots a star's temperature against luminosity. High-mass stars will continue to be enveloped in dust until their phase of rapid gravitational contraction is over, while low-mass stars become visible after the stellar wind clears the surrounding dust and gas.
During this transitional phase, the luminosity remains roughly constant and the surface temperatures start to build up. Visibility through visible light only becomes possible after the stellar wind clears away the surrounding material, which can happen at this stage for lower-mass stars. However, for high-mass stars, they may still be obscured by dust until the end of their early contraction. The protostar's ability to trap heat is what defines the end of the rapid-collapse stage and paves the way towards its eventual maturity into a main-sequence star.