If there is a valid reason for you to briefly leave the scene of the accident (e.g. to get assistance) and then return, it would be up to the court to decide whether your actions are lawful.