added model close handeling