A Gaza deal is "on the brink", President Joe Biden has said in his final foreign policy address.