The Giants totaled four hits and five runs in the top of the 11th to snap a four-game losing streak