public function logout($userid = null, $options = array())
	{
		// Get a user object
		$user = ($userid ? \User::getInstance($userid) : \User::getInstance());

		// Build the credentials array.
		$parameters['username'] = $user->get('username');
		$parameters['id']       = $user->get('id');

		// Set clientid in the options array if it hasn't been set already.
		if (!isset($options['clientid']))
		{
			$options['clientid'] = $this->app['client']->id;
		}

		// OK, the credentials are built. Lets fire the onLogout event.
		$results = $this->app['dispatcher']->trigger('user.onUserLogout', array($parameters, $options));

		// Check if any of the plugins failed. If none did, success.
		if (!in_array(false, $results, true))
		{
			// Use domain and path set in config for cookie if it exists.
			$cookie_domain = $this->app['config']->get('cookie_domain', '');
			$cookie_path   = $this->app['config']->get('cookie_path', '/');

			setcookie($this->app->hash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);

			return true;
		}

		// Trigger onUserLoginFailure Event.
		$this->app['dispatcher']->trigger('user.onUserLogoutFailure', array($parameters));

		return false;
	}