Sensex ends in the red, closes 53.73 points at 40,248.23