Thanks to whoever wrote this!
In an effort to better understand KoLMafia syntax I've played around with and changed the script a bit
my version uses your reported HP to determine what you should be doing in the game, and as such will properly finish the dungeon if you stop partway through...