bugfix: set handles to NULL after closing