A topological characterisation of endomorphism monoids of countable structures