Britain should walk away from the EU unless it secures the deal it wants, the US president says.