This may not help you a lot but I think that's a pretty inelegant solution. All non-global functions will stop on level load either way, so you only have to stop global functions manually (which you barely need to). I do this with a do_exit variable (thus while(!do_exit)...) which I set to 1 prior to level_load and reset it one frame later.