Output pin runs through the while loop.
Added keyboard interrupt and pin cleanup.