Auto connect coordinates of drawing so i can use the paint bucket fill tool

if i draw a shape with the pen or line tool. If i did not draw it perfectly connecting the dots, i cannot fill it with the paint buck fill tool. How can you tell it to just close the structure