FBI director Christopher Wray has said he will resign at the end of Joe Biden's term in January, before Donald Trump comes into office.