Fix segfault when closing the application

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