The first with means "as" or "while". It says when the "closing in" is happening -- at the same time as the "scrambling". The second with means "in the manner of" or "having".
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.