To apply for permanent residence, an H-1B alien might choose to file Form I-140 (i.e. employment-based immigrant petition) or a PERM labor certification application. If the worker filed one of these forms at least 365 days before the end of his six-year H-1B time limit and the application is still pending, then he can extend his H-1B status beyond the six-year limit.
In other words, he won’t be forced to leave the country since he’s waiting for a decision on his immigrant petition. The hypothetical worker can obtain such an extension on an annual basis, and there is no limit to the number of times he can obtain it, provided his immigrant petition is still pending.