avoided null point exception
avoided null point exception
added close method.
Merge pull request #41 from probepark/master

avoided null point exception