Then you should probably see a doctor about it. When the penis swells - (when it's hard) it closes off the urethra so that no urine can travel out. If you are in fact peeing when you are "almost" cumming it seems to me there's a functional problem. In other words when you're hard your urethra cannot let urine pass through, unless there is some sort of problem or issue with you, and seeing a doctor wouldn't hurt matters.
On the other hand if it's just that it *feels like* you're going to pee, well like everyone else said here- considering that cumming goes through the same nerve network as peeing, a similar sensation is a logical conclusion.