It's probably because of lag and the like. Whilst you have officially disconnected from the network (as everyone else can see) your client will sort of "freeze" in that you won't be able to see joins/parts/text/kicks etc etc. This sometimes happens when you're being packeted.
Other times you find that when you manually /quit and reconnect, your nickname is still there. It then quits after you've reconnected.
As far as I know, there is nothing you can do about this. If there is no activity in the channel(s) you're in for a long time, try typing /hop in the channel - if it doesn't rejoin, it probably means you have (or are going to) disconnect. In that case, close mIRC and reconnect again.
Regards,