Add clean shutdown to main program. Fix error in GPIO deinit call.