S-matrix poles close to thresholds in confined geometries