Bugfix: Occasional null pointer exception when an agent is killed, due to synchronization issue