The wasClean read-only property of the CloseEvent interface returns true if the connection closed cleanly.
wasClean
MDN Reference