proper close handling with different status conditions
changes for proper close status.
remove debug printing