To contrast, in my early days of options trading with Interactive Brokers, they had closed a spread ~10 minutes before expiry at a loss, which turned profitable 8 minutes later.
Contacted support, and they responded within 2 minutes explaining exactly why this had been done (risk profile at the time, and insufficient margin to cover). They answered all my questions and even explained what I should do to mitigate this issue going forward.