I use a steady hand. If you need to correct wipe with damp rag or if it has dried touch up with ceiling paint color.
When I paint up to the ceiling, I always leave about 1/4" unpainted. Then I get a 1" artist brush (the kind with stiff, white bristles) and touch it up close to the molding while standing on a step ladder with a wide step. (Every household should have one of these wide step, step ladders.)
The secret is not to overload your brush with paint...no one can tell much from the ground level.
I use a small (1" or so), squared bristle, stiff haired artist paintbrush and press the brush vertically up to the seam between the ceiling and the wall and pull the brush in downward strokes away from the ceiling. If you start at that point and pull the brush downward you won't get any paint on the ceiling. Wipe the brush frequently to avoid any splatters.