Shaky Proteas hang on as late wickets tumble