GenServer.stop/3 should be useful here:
Synchronously stops the server with the given
reason.
Theterminate/2callback of the givenserverwill be invoked before exiting. This function returns:okif the server terminates with the given reason; if it terminates with another reason, the call exits.


















