Function to correctly free particles memory