Note that if $T$ is reduced, this morphism has dense image.
If $T$ is a locally compact totally disconnected hausdorff space, it can be given explicitely a reduced scheme structure, which is affine iff $T$ is compact. Besides $T \to Spec \Gamma(T)$ is an dense open immersion. Thus it is not closed as long $T$ is not compact. I've proven this here. Thus a counterexample would be $T = \mathbb{Q}_p$.
I expect that others will show you more "natural" examples.

