Man shot by police after hourslong standoff