serial: fix port cleanup and use-after-free
Merge pull request #36 from tmatth/use_after_free

serial: fix port cleanup and use-after-free