Sri Lanka beat South Africa in 4th ODI