Move backend to separate file, trying to implement server shutdown.
Fixed server shutdown.