Buy-ins arise from two situations: a share-recall the borrower could not replace, and a fail-to-deliver that has aged past its mandatory close-out deadline. The executing firm has no obligation to get a good price; it has an obligation to deliver, so buy-ins routinely print at the worst level of the session.
There is no notice requirement that gives you time to trade out on your own terms. For a short seller, the practical defence is to avoid holding size in names with tight borrow and high utilization.
Example: 30,000 shares are bought in during a squeeze. The stock ranged $22 to $31 that day and the buy-in filled at $30.40, roughly $250,000 worse than the day's low would have been.
Related: share-recall, fail-to-deliver, threshold-securities-list, short-squeeze, regulation-sho