You are probably disconnecting from Yahoo Messenger because you are going to your mailbox and you are signing into Mail Chat automatically. Besides your username, you should see an option, "Available". Click on it and change your status to "Invisible" or "Sign out of Chat". You will then be able to log back into IM and stay logged in. You cannot be signed into both IM and Mail Chat at the same time.