When passing another vehicle, it is safe to return to your lane if you:

Before returning to your original lane after passing, you must make sure you are not dangerously close to the vehicle you have just passed. When you can see both of the vehicle's headlights in your rearview mirror, you may have enough room to return to the lane.
DMV Writen Test