If it's after you've been idle, then mIRC may not know you were disconnected until you try sending something to the server. That may be why you see it happen right when you try saying something. Make sure "Check connection time out" is enabled in mIRC's options (Alt-O > Connect > Options) and see if that helps.
And, as was already asked, please include the actual disconnect message.