Then, at about 12 a.m., RM, Jin, SUGA, J-hope, Jimin, V and Jungkook — the members of BTS — got to the terminal, which remained open.

It was important that the public not catch a glimpse of the K-pop group members because their appearance on “The Tonight Show” was a surprise.

“They were not in the public areas while we were still open,” Ms. Conti said. “It was top secret.”

The “Tonight Show” declined to comment, but on Twitter, a producer for the show wrote that the episode was “our love letter to this city” and noted that BTS was “game for everything.”

It wasn’t until 2 a.m., when the terminal had officially closed to the public, that BTS set foot on the main terminal floor.

They had two hours to nail the perfect video clip of “ON” from their new album, “Map of the Soul: 7,” before the terminal’s cleaning staff came in to wash the floors. The doors would open to the public again at 5:15 a.m.

Jimmy Fallon and BTS rode in a special subway.

The episode, which aired Monday night, also featured a #FallonAsksBTS segment in which the seven members of the group rode the subway with Mr. Fallon while answering some of the questions their fans, also known as the army, posed on Twitter.