Implements logging out.