Stocks ended one of their worst weeks in history as coronavirus fears grip global markets.