Update onclose function.
Merge pull request #317 from gsn/master

Update onclose function.