Removing the key signature at the end of a line

According to normal typesetting conventions, LilyPond typesets key changes at the end of the line, when the change appears at a line break. This example shows how to change this default to only print the new key signature at the beginning of the next line.

\version "2.24.0"

%% http://lsr.di.unimi.it/LSR/Item?id=124

\paper {
  ragged-right = ##t
  tagline = ##f
}

\score {
   \relative c' {
    \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible
    c d e f | g a b c | \break
    \key d \major
    d cis b a | g fis e d |
  }
}