Some relative clauses will refer to more than a single word in the preceding text; they can modify an entire clause or even a series of clauses.
Charlie didn't get the job in administration, which really surprised his friends.
Charlie didn't get the job in administration, and he didn't even apply for the Dean's position, which really surprised his friends.
A relative clause that refers to or modifies entire clauses in this manner is called a sentential clause. Sometimes the "which" of a sentential clause will get tucked into the clause as the determiner of a noun:
Charlie might very well take a job as headmaster, in which case the school might as well close down.