The Upwork team regularly checks listings for ToS violations. If a job listing is found to be in violation of the terms, it will be closed and your connects will be returned to you. If you withdraw your proposal yourself, you won't get back your connects. Just let Upwork handle the "scam" appraisal.
I would like to confirm what Varun has shared on his post. When withdrawing proposals, Connects used for those proposals will not be returned to you. However, if a job post has been taken down for a violation of the Upwork Terms of Service, the Connects used for those proposals will be automatically returned to your account. You may check your Connects History page (Settings > Membership & Connects > Connects History) to be able to track your Connects.