In many cases, mIRC won't know you're about to disconnect: if the connection fails, if you're killed-ghosted-or whatever by the server, etc pp. "On disconnect" may trigger several seconds after the actual disconnect.
However, you can overwrite the /disconnect /quit and /exit commands to include a "[scon -a] partall" - or create a new custom command to partall-then-disconnect?