We prove that the outer automorphism group $Out(G)$ is residually finite when the group $G$ is virtually compact special (in the sense of Haglund and Wise) or when $G$ is isomorphic to the fundamental group of some compact $3$-manifold. To prove these results we characterize commensurating endomorphisms of acylindrically hyperbolic groups. An endomorphism $\phi$ of a group $G$ is said to be commensurating, if for every $g \in G$ some non-zero power of $\phi(g)$ is conjugate to a non-zero power of $g$. Given an acylindrically hyperbolic group $G$, we show that any commensurating endomorphism of $G$ is inner modulo a small perturbation. This generalizes a theorem of Minasyan and Osin, which provided a similar statement in the case when $G$ is relatively hyperbolic. We then use this result to study pointwise inner and normal endomorphisms of acylindrically hyperbolic groups.