Added frame close event cancelling

Adds a check whether the OnClose event handler returned false, in which
case it will not remove the object.