McCarthy close to becoming speaker in late-night vote