To fix #123.

Socket was not getting closed in case of gram job and ports were not
reset for both gram and gridftp use.