Manually trigger cleanup of background threads.
Drains pending traces via flush() before stopping the background
threads. Pass timeout=0 to skip the drain entirely (e.g. in error
paths or signal handlers where blocking on network I/O is
unacceptable).