Make sure LogCapture cleans up global state it may affect.