Fix bug in logout view.

Get the 'next' url before the session is flushed.