In my experience, that typically happens shortly before either the account gets locked (326 error code) or your application gets restricted.
I have similar restrictions on my platform but I use 1 follow per 2 minutes and 1 unfollow per 2 minutes with daily caps at 300 followers and 1,000 unfollows. I also use a formula to predict whether the user is around the 5,000 following limit to temporarily lock accounts that need to fix their ratio (though 16,000 followers and 10,000 following would not be caught by this so it’s a moot point). If someone manages to get the 161 error after bypassing my filter then I freeze all follows/unfollows in my app for 10-30 minutes and lock that individual account for 3 hours to let it clear.