How to disable a microcontroller port once enabled?
Pretty much every microcontroller will have it's ports' default state as 'input'. So just set the ports as inputs and you should be all set. One potential gotcha is if the pin has an internal pull-up or pull-down set, which could cause some issues, depending on your circuit. Lastly, most datasheets provide the default state of the bits in a given register. So to get the register back to how they were after the chip powered on, simply set the bits to their default state.