Five years after his appointment as a chamber musician in the Court of the Duke of Sachsen-Weimar, the hard-working Bach was passed over for the job of Kapellmeister (Director of Music). The word quickly got out and, when Bach was offered a similar post in the nearby, rival Court of Anhalt-Cöthen, he happily accepted that offer.
When Bach handed in his resignation, the Duke of Weimar retaliated by throwing Bach in jail for thirty days. The hard-working Bach spent those thirty days wisely. It was there that he began composing his first chorale preludes for organ. These were eventually published as part of his Orgelbüchlein (Little Organ Book).