Fix segfault when closing the application

Authored by tfella on Jun 3 2020, 12:53 PM.