Does a context switch happen when a process has terminated?
Yes, a context switch happens. After P1 ends the state of P2 must be loaded. The only difference with a regular context switch is that the state  of P1 does not need to be saved as it is not needed for a later restore.

Whether the OS actually applies this optimization or simply performs a regular context switch and then later discards the saved context for P1 depends on the implementation.