Socket handling updates

- explicitly close opened socket
- set socket timeout (3s)