cleanup in openPort
close open file on error
Merge pull request #2 from ungerik/master

Cleanup in openPort