You GenServer is not trapping exits so when the supervisor sends it an exit signal to terminate the GenServer it just immediately dies. You need to implement an init/1
callback in which you do, amongst other things, a Process.flag(:trap_exit, true)
which then makes the GenServer process catch that exit signal, call the terminate/2
callback and then die.
3 Likes