You can leave the airport without a problem. When the first part is domestic, there is no problem leaving the airport as you've already passed customs when entering the country. 9 hours is not a lot of time, as it takes about 45 minutes to get to the city center using the AirTrain - LIRR connection (take the Airtrain to Jamaica station and then the LIRR from Jamaica to Penn Station). You can see Midtown (Times Square, Empire State Building, Rockefeller Center, etc) in that time.
You can leave the airport