[fix] remove broken/incomplete code and add onExit handler