Generally, it would be a DM call. You can always tell your DM that you are attempting to leave an encounter, and he will tell you whether it is possible and whether you will need to make any checks in order to do so. For example, if you are playing with a battlemat, the DM may ask you how you are moving your PC, and he will determine the reactions of the monsters to your attempt to get away. For example, some monsters may ignore you and focus on the PCs remaining in the fight, while others may choose to pursue you or attack you with a ranged weapon to try and stop you from getting away.
Apart from the mechanical process of getting away, you may want to bear in mind any potential problems you might be causing yourself and the rest of the people you are gaming with. If you are not able to reunite with the other PCs after the fight, the DM may have to deal with a split party. Alternatively, the DM may choose to focus on the other PCs for the remainder of the game and only get back to you after the other PCs have completed the adventure and returned to town as well. In addition, some of the other players may not be happy that you decided to leave in the middle of a fight and may have reactions ranging from gentle ribbing to scorn to outright hostility.