As Ruben said, the returned result message from the database handler is "Server shutdown in progress", whereas the "limit" is simply the end of the query sent to the server.

HTTP 5xx errors are server related (4xx generally being script related somehow); 522 (Connection timed out) and 524 (ultimately being the same over a Content Delivery Network such as Cloudflare). Judging just purely off of the error messages, it sounds like you were experiencing downtime because the server restarted.

As these are server errors there's really nothing really that UBB.threads script support can do; this would generally be something to direct at your web host.