No, ptr_remove can not remove two panels at once. This looks like a typical script bug, such as accessing pointers to already-removed objects.

Unfortunately your script does not speak for itself... When writing scripts, make it a habit to have clear structured code. Use indentations and don't clutter lines with rat's nests of commands. Then other people and yourself have a better chance to see what the script is doing. Be always aware of when pointers are valid and when not, and don't pass pointers to coroutines while removing them in other functions. Then such problems won't happen. If they do, they might really be engine bugs.