US President Donald Trump has said an initial agreement aimed at ending the war with Iran is close after posting that he had cancelled strikes on the country.