Characterisation of Terminating Logic Programs