In this case you would likely do a 15 year term loan. The previous comment is misleading or incorrect in stating that you have to do a new 30 year loan always when refinancing.
When I refinanced they let me pick a term of a 27 years, of course it was at the 30 year rate. There is no advantage to doing this versus just automatically overpaying the mortgage every month to tune in the target payoff date.