show/hide this revision's text 2 added 63 characters in body; deleted 9 characters in body

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.

show/hide this revision's text 1

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.