Clean up middleware.