SFTP: add _close_handle() function and close handle on put failure