Fix a crash seen when closing window.

Caused by not taking ownership of the AbstractPane
which would result in Application destroying it leaving
us with a dangling pointer.

[TIMOB-12883]