perform respawning on the "close" event instead of "exit"

It seems "close" is always called while "exit" is only called sometimes