added gpio closing sequence