Ab initio study of a mechanically gated molecule: From weak to strong correlation