Do you have 4 whole hours or is that 4 hours from ETA to ETD i.e. scheduled arrival time 1300, scheduled departure time 1700? Are you flying domestic-domestic, domestic-international, international-domestic? Will you have luggage? Will you have all the boarding passes for your next flight?
If you have only 4 hours from ETA to ETD then I think you would be cutting it very fine to take a trip into SF and back to the airport. Between the time taken to get off the plane and the time needed to go through security and be at the departure gate before the next flight, you may only have 3 hours or less.
However, have a look at this thread, you *might* be able to do the same thing (tripadvisor.com.au/ShowTopic-g60713-i30-k704…) but it will very much depend on the true amount of time you have.
There is also a Top Question "Long Layover at San Francisco Airport. What to do?".
Personally I would not consider 4 hours to be a long time and I would probably not leave the airport, but I am very risk averse and would not want to miss my next flight.
I would say you definitely don't have time for Alcatraz.
Can you move the subsequent flight to the next day and have a day in SF? It would still be a whistle-stop visit but far better than constantly watching (if you'll pardon the pun) the time.
Edited: 6:31 pm, December 12, 2013