We study the mechanism of decay of a topological (winding-number) excitation due to finite-size effects in a two-dimensional valence-bond solid state, realized in an $S=1/2$ spin model ($J$-$Q$ model) and studied using projector Monte Carlo simulations in the valence bond basis. A topological excitation with winding number $|W|>0$ contains domain walls, which are unstable due to the emergence of long valence bonds in the wave function, unlike in effective descriptions with the quantum dimer model. We find that the life time of the winding number in imaginary time diverges as a power of the system length $L$. The energy can be computed within this time (i.e., it converges toward a quasi-eigenvalue before the winding number decays) and agrees for large $L$ with the domain-wall energy computed in an open lattice with boundary modifications enforcing a domain wall. Constructing a simplified two-state model and using the imaginary-time behavior from the simulations as input, we find that the real-time decay rate out of the initial winding sector is exponentially small in $L$. Thus, the winding number rapidly becomes a well-defined conserved quantum number for large systems, supporting the conclusions reached by computing the energy quasi-eigenvalues. Including Heisenberg exchange interactions which brings the system to a quantum-critical point separating the valence-bond solid from an antiferromagnetic ground state (the putative deconfined quantum-critical point), we can also converge the domain wall energy here and find that it decays as a power-law of the system size. Thus, the winding number is an emergent quantum number also at the critical point, with all winding number sectors becoming degenerate in the thermodynamic limit. This supports the description of the critical point in terms of a U(1) gauge-field theory.