The variational capacity with respect to nonopen sets in metric spaces