Logout+ stop plugin:
if(!me.isAlive())
{
Log("I died, logging off ;(");
CloseGame();
StopPlugin("YourPluginFolderName\\YourPluginName.dll");
}
Alternative: Go to character screen + stop plugin
if(!me.isAlive())
{
Log("I died, going to character screen ;(");
LeaveWorldToCharacterSelect()();
StopPlugin("YourPluginFolderName\\YourPluginName.dll");
}