Fix pid file creation and make stop script