function phidgetExit()
%PHIDGETEXIT Close a connection to a Phidget
%   phidgetExit() closes the connection to an attached Phidget and
%   releases system resources associated with the Phidget.
%
%   After calling this function the global variable PHIDGET is set to
%   the empty array.

global PHIDGET;

if isempty(PHIDGET)
    return
end

calllib('phidget21', 'CPhidget_close', PHIDGET);
calllib('phidget21', 'CPhidget_delete', PHIDGET);
PHIDGET = libpointer;