TL;DR: The claws are a part of his natural physiology. They're housed within his bones and likely connected to him/controlled by ligaments and tendons, and never "eject".
First, let's go over historical Wolverine.
Bonus reading: How exactly do Wolverine's claws come out?
Up until the 90's, everyone (including Wolverine) believed that his claws had been surgically implanted. In early Wolverine comics, he mentions that they are "bionic" in nature. This was "confirmed" in the Weapon X storyline of Marvel Comics Presents, where adamantium is injected into his body, covering his bones. They purposefully continue injecting extra and the overflow is (somehow magically) formed into retractable claws.
The Marvel trading cards around the same time explained this a little further.

But it's all lies.
In X-Men 25, Magneto rips the adamantium from Wolverine's body. It is revealed that Wolverine has natural bone claws - which the adamantium simply bonded to, creating his signature claws.

The story Origin: Wolverine would later confirm that Wolverine has had these bone claws since birth, or at least since his powers first manifested.

The movie X-Men Origins: Wolverine kept with this new history.

In the X-Men movie, we can see an x-ray of Wolverine's claws. You can see how they grow wider at the bases of the claws, almost connecting. This width, plus the connection to a tendon would keep the claws from fully ejecting from his arms.

In X-Men Origins: Wolverine, we see how they come out (I think this may have actually been from the special features and not the movie itself. Please don't make me watch it again to confirm, I beg you.)
We can see how they slide between the knuckles.
Is it possible for Wolverine to push his claws through his palms instead of his knuckles?
DavRobo60 asked that very question earlier. The answer was: maybe.
So why don't the claws flop around or angle differently?
This is never fully explained 100%. The x-ray, which is from the movie (and admittedly not necessarily comic-canon-accurate) shows an area within the forearm that is effectively hollowed out. It's possible that in the comics, his bone isn't split like that, and that the claws are fully encased, but I've never seen anything confirming/denying that. That leaves us with the same basic way all of our other bones are normally connected: tendons, muscles, and cartilage. Add in the narrow spaces and lack of wiggle-room, and the claws aren't going anywhere but straight out.
Wait. Where do the claws extend out of? That might make some difference.
This is one of the instances that the movies did fix a huge logistical problem: exactly where the claws come out. Look back up at the trading card and the scan from X-Men 25. You can see that his claws come out from the backs of his hands.
Now compare that against the movie version. The claws extend from between the knuckles. Extending from between the knuckles would provide extra stability.
This all ties back to whether or not he can extend them through his palms, or whether or not he can bend his wrists.

But... Aren't his claws too long?!
In most cases, yes. Let's break this down.
The length of his claws has always fluctuated - from artist to artist, and movie to movie.
Officially, Wolverine is listed as being 5'3" (63in/160cm).
A typical human is seven and a half heads high, though many comic artists use a guide of eight. For sake of argument (since the proportional lengths would be greater), we'll assume a ratio of 7.5 heads high. That means Wolverine's head size is 8.4" (21cm). The average forearm is roughly 1.25 heads long. So, we're looking at a forearm length of 10.5" (26.67cm). So, for his claws to fit within his forearms, they must be 10.5" or less.
Marvel does not currently list an official claw length, but let's look at the trading card above. Each claw is a monstrous 17.8" (45.21cm) long! For those claws to fit within his forearms, Wolverine would have to be 8'9" (106.8in/271.27cm).
OK, but what about the movies? We see that they fit there. Unfortunately, we again have weird conflicting information.
The x-ray from X-Men 1 appears to show the claws resting inside his wrists when retracted. Obviously, this doesn't make any sense at all, or he'd never be able to bend his wrists - ever. We see him bending his wrists in normal motion, so we can conclude that this is either
- an error (in the X-Men movies?! gasp!)
- some sort of channel (natural or otherwise) and not part of the claw that we see in his wrist/hand. We see in the video that the claws push through joints in the wrists. We may be seeing some sort of protection his body has evolved to keep the claws from damaging himself internally.
Honestly, I'd stick with Occam's razor and say it's just an error.
This seems to have been corrected by the time the x-ray video was produced though. Here, we see the claws retracting fully into the forearms. This allows his wrists to function normally as expected.