Apparently in Windows in cmd the terminal size is not correctly reported.
In win32 apis there are two sizes - one for window and one for the buffer. Currently it reports the buffer size instead of the window size. So if set the buffer height/lines to 9999, that is the value it returns instead of the window height which is lot smaller.
Seems like need to do a bit more calculation. https://stackoverflow.com/a/12642749
This is not an issue with the new windows terminal, only issue with the cmd.exe.