Recall the definition of the vector valued Sobolev space $W^{1,p}(\Omega;\mathbb R^N)$, where $\Omega\subset\mathbb R^n$ is either $\mathbb R^n$ or a $C^1$ bounded domain, and $1<p<\infty$ — we say $u\in L^p(\Omega;\mathbb R^N)$ is in $W^{1,p}(\Omega;\mathbb R^N)$ if $\mathrm Du \in L^p(\Omega;\mathbb R^{nN})$, with the usual norm. For any compact set $S\subset\mathbb R^N$, we can also define $$W^{1,p}(\Omega;S):=\{u\in W^{1,p}(\Omega;\mathbb R^N)\ :\ u(\cdot)\subset S\hbox{ a.e.}\}$$ which can be sen to be strongly closed.
However, without any convexity assumption on $S$, why is it the case that $W^{1,p}(\Omega;S)$ is weakly closed? Recall that $W^{1,p}(\Omega;\mathbb R^N)$ is reflexive.
The Rellich-Kondrachov theorem (applied to $B_r (x) \subset\subset \Omega$ for $x\in\Omega$ arbitrary and $r>0$ sufficiently small) implies $W^{1,p}(\Omega)\hookrightarrow L^p_{loc}(\Omega)$, where the embedding is compact.
Hence, if $f_n \to f$ weakly in your vector valued Sobolev space and with $f_n$ taking values in $S$ almost everywhere, then there is a subsequence with $f_n \to f$ almost surely. Since $S$ is closed (we do not need compactness actually), this implies that $f$ also takes values in $S$ almost surely.