I never noticed if that happened before so i just tried a few tests.
Mail is the only app I use that appears to do this. it only happens if Mail was the last window you minimized to the Dock before you close another program. If there's any intervening minimize or opening of another app Mail will remain as it should in the Dock.
Weird, but I don't see it as a real bug, more like a non-severe hiccup.