How to test terminate callback for GenServer

GenServer.stop/3 should be useful here:

Synchronously stops the server with the given reason.
The terminate/2 callback of the given server will be invoked before exiting. This function returns :ok if the server terminates with the given reason; if it terminates with another reason, the call exits.