Batman disappears by taking advantage of human nature and human assumptions about what is possible the same way a stage magician might. Batman's ability to disappear is more a skill of misdirection than of supernatural capacity. While it may appear to be almost a magical power, he is a student of human nature and takes advantage of preconceived notions to make himself "disappear".
Misdirection and Distraction
In almost all of your examples, Batman takes advantage of having wide areas where it can be challenging to figure out which way he disappeared (rooftops and windows are great for this). Being an extraordinary acrobat doesn't hurt either allowing him to "hide in plain sight" by using shadows people simply don't consider capable of cloaking a man. The train yard scene could have easily been one of those.
In enclosed spaces, we are forced to presume a pre-configured escape route. Smoke, loud spaces, and other distractions make it easy to disappear from people who simply don't know enough about him to realize what happened.
In many of the DC continuities, Batman was trained by Zatara (a stage magician who happens to actually be able to do real magic) and he uses this timing, this knowledge of human nature and the preconceived notions people have about what is possible, to give the illusion of disappearing, even from people such as Superman.
Preparation
Batman is a tactician, first and foremost, so he tends to choose circumstances which allow him quick entry and exit and more than likely has already chosen at least three different ways of "disappearing" from anyplace he has had the time to study and prepare for. An illusionist fools you because you believe you understand what is happening and he has already set the stage for you to be misdirected.
Preparing to "disappear" from people like Superman requires both timing, circumstance and a conveniently positioned lead-lined wall or bio-masking technology (which he has used to mask his heart-rate and respiration from superhumans, Superman in particular). More than likely, Superman if he were really motivated, could find a cloaking Batman, but if Batman really wanted to hide from Superman, he wouldn't ever appear in person due to the expected difficulty of hiding from a man with an entire battery of super-senses.
Preconceived Notions (Psychology)
How often when people are looking for a person, do they think to look up? Batman takes advantage of that socialized two-dimensional thinking. Most importantly, he has conditioned people to believe he has supernatural abilities. He maintains this mystique in order to keep people off-guard.
Hiding from the Flash, in your example isn't actually that difficult, because he "disappears" while the Flash is resolving his crime-fighting action. If you notice, the Flash looks through the building at superspeed but only looks as if the Batman was limited to movement on the ground. A line to a nearby building might be all Batman needed to avoid detection AND appear to magically disappear. He could just as easily hide in the shadows, choosing a position where the Flash's superspeed scan (which is still just a really fast open-doors, look-inside kind of thing) and simply hidden better than the Flash could find.
Looking at your two humor examples may have more truth to them than you may think. What stops him from doing exactly that? People are easily fooled by stage magicians because unless you understand the trick, you believe the magic. Batman is simply a better magician than most and makes it his business to know when the best time to "disappear" in any conversation. More than likely he engineered the conversation so he could time it just right.